Skip to content

Commit 44b2891

Browse files
committed
Add examples for 8.6.3
1 parent 597abcb commit 44b2891

File tree

3 files changed

+90
-1
lines changed

3 files changed

+90
-1
lines changed

Examples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<dependency>
1515
<groupId>com.aspose</groupId>
1616
<artifactId>aspose-cells</artifactId>
17-
<version>8.6.2</version>
17+
<version>8.6.3</version>
1818
</dependency>
1919
</dependencies>
2020
<repositories>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2001-2016 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.BuiltinStyleType;
11+
import com.aspose.cells.Cell;
12+
import com.aspose.cells.Style;
13+
import com.aspose.cells.Workbook;
14+
import com.aspose.cells.examples.Utils;
15+
16+
public class UsingBuiltinStyles {
17+
18+
public static void main(String[] args)
19+
throws Exception {
20+
21+
String dataDir = Utils.getDataDir(UsingBuiltinStyles.class);
22+
String output1Path = dataDir + "Output.xlsx";
23+
String output2Path = dataDir + "Output.ods";
24+
25+
Workbook workbook = new Workbook();
26+
Style style = workbook.createBuiltinStyle(BuiltinStyleType.TITLE);
27+
28+
Cell cell = workbook.getWorksheets().get(0).getCells().get("A1");
29+
cell.putValue("Aspose");
30+
cell.setStyle(style);
31+
32+
workbook.getWorksheets().get(0).autoFitColumn(0);
33+
workbook.getWorksheets().get(0).autoFitRow(0);
34+
35+
workbook.save(output1Path);
36+
System.out.println("File saved " + output1Path);
37+
workbook.save(output2Path);
38+
System.out.println("File saved " + output2Path);
39+
}
40+
}
41+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2001-2016 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.files.handling;
9+
10+
import com.aspose.cells.LoadDataOption;
11+
import com.aspose.cells.LoadOptions;
12+
import com.aspose.cells.Workbook;
13+
import com.aspose.cells.examples.Utils;
14+
15+
public class LoadVisibleSheetsOnly {
16+
17+
public static void main(String[] args) throws Exception {
18+
String dataDir = Utils.getDataDir(LoadVisibleSheetsOnly.class);
19+
String sampleFile = "Sample.out.xlsx";
20+
String samplePath = dataDir + sampleFile;
21+
22+
// Create a sample workbook
23+
// and put some data in first cell of all 3 sheets
24+
Workbook createWorkbook = new Workbook();
25+
createWorkbook.getWorksheets().get("Sheet1").getCells().get("A1").setValue("Aspose");
26+
createWorkbook.getWorksheets().add("Sheet2").getCells().get("A1").setValue("Aspose");
27+
createWorkbook.getWorksheets().add("Sheet3").getCells().get("A1").setValue("Aspose");
28+
// Keep Sheet3 invisible
29+
createWorkbook.getWorksheets().get("Sheet3").setVisible(false);
30+
createWorkbook.save(samplePath);
31+
32+
// Load the sample workbook
33+
LoadDataOption loadDataOption = new LoadDataOption();
34+
loadDataOption.setOnlyVisibleWorksheet(true);
35+
LoadOptions loadOptions = new LoadOptions();
36+
loadOptions.setLoadDataAndFormatting(true);
37+
loadOptions.setLoadDataOptions(loadDataOption);
38+
39+
Workbook loadWorkbook = new Workbook(samplePath, loadOptions);
40+
41+
System.out.println("Sheet1: A1: " + loadWorkbook.getWorksheets().get("Sheet1").getCells().get("A1").getValue());
42+
System.out.println("Sheet2: A1: " + loadWorkbook.getWorksheets().get("Sheet2").getCells().get("A1").getValue());
43+
System.out.println("Sheet3: A1: " + loadWorkbook.getWorksheets().get("Sheet3").getCells().get("A1").getValue());
44+
45+
System.out.println("Data is not loaded from invisible sheet");
46+
}
47+
}
48+

0 commit comments

Comments
 (0)