Skip to content

Commit cc6d08e

Browse files
committed
Add examples for 8.6.1
1 parent 5e3bb09 commit cc6d08e

File tree

9 files changed

+182
-0
lines changed

9 files changed

+182
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2001-2015 Aspose Pty Ltd. All Rights Reserved.
3+
*
4+
* This file is part of Aspose.Cells. The source code in this file
5+
* is only intended as a supplement to the documentation, and is provided
6+
* "as is", without warranty of any kind, either expressed or implied.
7+
*/
8+
package com.aspose.cells.examples.articles;
9+
10+
import com.aspose.cells.VbaProject;
11+
import com.aspose.cells.Workbook;
12+
import com.aspose.cells.examples.Utils;
13+
14+
public class AddLibraryReferenceToVbaProject {
15+
16+
public static void main(String[] args)
17+
throws Exception {
18+
19+
String dataDir = Utils.getDataDir(AddLibraryReferenceToVbaProject.class);
20+
String outputPath = dataDir + "Output-1.xlsm";
21+
22+
Workbook workbook = new Workbook();
23+
24+
VbaProject vbaProj = workbook.getVbaProject();
25+
26+
vbaProj.getReferences().addRegisteredReference("stdole", "*\\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\\Windows\\system32\\stdole2.tlb#OLE Automation");
27+
vbaProj.getReferences().addRegisteredReference("Office", "*\\G{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}#2.0#0#C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE14\\MSO.DLL#Microsoft Office 14.0 Object Library");
28+
29+
workbook.save(outputPath);
30+
System.out.println("File saved " + outputPath);
31+
}
32+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2001-2015 Aspose Pty Ltd. All Rights Reserved.
3+
*
4+
* This file is part of Aspose.Cells. The source code in this file
5+
* is only intended as a supplement to the documentation, and is provided
6+
* "as is", without warranty of any kind, either expressed or implied.
7+
*/
8+
package com.aspose.cells.examples.articles;
9+
10+
import com.aspose.cells.HtmlLinkTargetType;
11+
import com.aspose.cells.HtmlSaveOptions;
12+
import com.aspose.cells.Workbook;
13+
import com.aspose.cells.examples.Utils;
14+
15+
public class ChangeHtmlLinkTarget {
16+
17+
public static void main(String[] args)
18+
throws Exception {
19+
20+
String dataDir = Utils.getDataDir(ChangeHtmlLinkTarget.class);
21+
String inputPath = dataDir + "Sample1.xlsx";
22+
String outputPath = dataDir + "Output.html";
23+
24+
Workbook workbook = new Workbook(inputPath);
25+
26+
HtmlSaveOptions opts = new HtmlSaveOptions();
27+
opts.setLinkTargetType(HtmlLinkTargetType.SELF);
28+
29+
workbook.save(outputPath, opts);
30+
31+
System.out.println("File saved " + outputPath);
32+
}
33+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2001-2015 Aspose Pty Ltd. All Rights Reserved.
3+
*
4+
* This file is part of Aspose.Cells. The source code in this file
5+
* is only intended as a supplement to the documentation, and is provided
6+
* "as is", without warranty of any kind, either expressed or implied.
7+
*/
8+
package com.aspose.cells.examples.articles;
9+
10+
import com.aspose.cells.Workbook;
11+
import com.aspose.cells.examples.Utils;
12+
13+
public class CheckVbaProjectSigned {
14+
15+
public static void main(String[] args)
16+
throws Exception {
17+
18+
String dataDir = Utils.getDataDir(CheckVbaProjectSigned.class);
19+
String inputPath = dataDir + "Sample1.xlsx";
20+
21+
Workbook workbook = new Workbook(inputPath);
22+
23+
System.out.println("VBA Project is Signed: " + workbook.getVbaProject().isSigned());
24+
}
25+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2001-2015 Aspose Pty Ltd. All Rights Reserved.
3+
*
4+
* This file is part of Aspose.Cells. The source code in this file
5+
* is only intended as a supplement to the documentation, and is provided
6+
* "as is", without warranty of any kind, either expressed or implied.
7+
*/
8+
package com.aspose.cells.examples.articles;
9+
10+
import com.aspose.cells.ExternalConnection;
11+
import com.aspose.cells.WebQueryConnection;
12+
import com.aspose.cells.Workbook;
13+
import com.aspose.cells.examples.Utils;
14+
15+
public class GetDataConnection {
16+
17+
public static void main(String[] args)
18+
throws Exception {
19+
20+
String dataDir = Utils.getDataDir(GetDataConnection.class);
21+
String inputPath = dataDir + "WebQuerySample.xlsx";
22+
23+
Workbook workbook = new Workbook(inputPath);
24+
25+
ExternalConnection connection = workbook.getDataConnections().get(0);
26+
27+
if (connection instanceof WebQueryConnection) {
28+
WebQueryConnection webQuery = (WebQueryConnection) connection;
29+
System.out.println("Web Query URL: " + webQuery.getUrl());
30+
}
31+
}
32+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright 2001-2015 Aspose Pty Ltd. All Rights Reserved.
3+
*
4+
* This file is part of Aspose.Cells. The source code in this file
5+
* is only intended as a supplement to the documentation, and is provided
6+
* "as is", without warranty of any kind, either expressed or implied.
7+
*/
8+
package com.aspose.cells.examples.articles;
9+
10+
import com.aspose.cells.Cell;
11+
import com.aspose.cells.FontSetting;
12+
import com.aspose.cells.Workbook;
13+
import com.aspose.cells.Worksheet;
14+
import com.aspose.cells.examples.Utils;
15+
16+
public class UpdateRichTextCells {
17+
18+
public static void main(String[] args)
19+
throws Exception {
20+
21+
String dataDir = Utils.getDataDir(UpdateRichTextCells.class);
22+
String inputPath = dataDir + "Sample.xlsx";
23+
String outputPath = dataDir + "Output.xlsx";
24+
25+
Workbook workbook = new Workbook(inputPath);
26+
27+
Worksheet worksheet = workbook.getWorksheets().get(0);
28+
29+
Cell cell = worksheet.getCells().get("A1");
30+
31+
System.out.println("Before updating the font settings....");
32+
33+
FontSetting[] fnts = cell.getCharacters();
34+
35+
for (int i = 0; i < fnts.length; i++) {
36+
System.out.println(fnts[i].getFont().getName());
37+
}
38+
39+
//Modify the first FontSetting Font Name
40+
fnts[0].getFont().setName("Arial");
41+
42+
//And update it using SetCharacters() method
43+
cell.setCharacters(fnts);
44+
45+
System.out.println();
46+
47+
System.out.println("After updating the font settings....");
48+
49+
fnts = cell.getCharacters();
50+
51+
for (int i = 0; i < fnts.length; i++) {
52+
System.out.println(fnts[i].getFont().getName());
53+
}
54+
55+
//Save workbook
56+
workbook.save(outputPath);
57+
58+
System.out.println("File saved " + outputPath);
59+
}
60+
}
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)