Skip to content

Commit 6287cee

Browse files
Merge pull request #5 from saqibmasood/master
Restructured the Examples directory
2 parents e1de5f7 + 79035ca commit 6287cee

File tree

228 files changed

+2480
-2679
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

228 files changed

+2480
-2679
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@ Out*/
2727
*.lic
2828
Data/*Out*
2929
.idea/
30-
pom.xml

Examples/pom.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.aspose</groupId>
5+
<artifactId>cells-java-examples</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<packaging>jar</packaging>
8+
<properties>
9+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10+
<maven.compiler.source>1.7</maven.compiler.source>
11+
<maven.compiler.target>1.7</maven.compiler.target>
12+
</properties>
13+
<dependencies>
14+
<dependency>
15+
<groupId>com.aspose</groupId>
16+
<artifactId>aspose-cells</artifactId>
17+
<version>8.4.2</version>
18+
</dependency>
19+
</dependencies>
20+
<repositories>
21+
<repository>
22+
<id>aspose-maven-repository</id>
23+
<url>http://maven.aspose.com/repository/repo/</url>
24+
</repository>
25+
</repositories>
26+
</project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.aspose.cells.examples;
2+
3+
import java.io.File;
4+
5+
public class Utils {
6+
7+
public static String getDataDir(Class c) {
8+
File dir = new File(System.getProperty("user.dir"));
9+
dir = new File(dir, "src");
10+
dir = new File(dir, "main");
11+
dir = new File(dir, "resources");
12+
13+
for (String s : c.getName().split("\\.")) {
14+
dir = new File(dir, s);
15+
}
16+
17+
System.out.println("Using data directory: " + dir.toString());
18+
return dir.toString() + File.separator;
19+
}
20+
}
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@
55
* is only intended as a supplement to the documentation, and is provided
66
* "as is", without warranty of any kind, either expressed or implied.
77
*/
8-
9-
package programmersguide.asposecells.creatingcharts.fundamentalfeatures.changechartpositionandsize.java;
8+
package com.aspose.cells.examples.charts.fundamental;
109

1110
import com.aspose.cells.*;
11+
import com.aspose.cells.examples.Utils;
1212

13-
public class ChangeChartPositionAndSize
14-
{
15-
public static void main(String[] args) throws Exception
16-
{
13+
public class ChangeChartPositionAndSize {
14+
15+
public static void main(String[] args) throws Exception {
1716
// The path to the documents directory.
18-
String dataDir = "src/programmersguide/asposecells/creatingcharts/fundamentalfeatures/changechartpositionandsize/data/";
19-
17+
String dataDir = Utils.getDataDir(ChangeChartPositionAndSize.class);
18+
2019
String filePath = dataDir + "book1.xls";
2120

2221
Workbook workbook = new Workbook(filePath);
@@ -36,8 +35,8 @@ public static void main(String[] args) throws Exception
3635

3736
//Output the file
3837
workbook.save(dataDir + "book1.out.xls");
39-
38+
4039
// Print message
4140
System.out.println("Position and Size of Chart is changed successfully.");
4241
}
43-
}
42+
}
Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,30 @@
55
* is only intended as a supplement to the documentation, and is provided
66
* "as is", without warranty of any kind, either expressed or implied.
77
*/
8-
9-
package programmersguide.asposecells.creatingcharts.fundamentalfeatures.createchart.java;
8+
package com.aspose.cells.examples.charts.fundamental;
109

1110
import com.aspose.cells.*;
11+
import com.aspose.cells.examples.Utils;
1212

13-
public class CreateChart
14-
{
15-
public static void main(String[] args) throws Exception
16-
{
13+
public class CreateChart {
14+
15+
public static void main(String[] args) throws Exception {
1716
// The path to the documents directory.
18-
String dataDir = "src/programmersguide/asposecells/creatingcharts/fundamentalfeatures/createchart/data/";
19-
20-
//Instantiating a Workbook object
17+
String dataDir = Utils.getDataDir(CreateChart.class);
18+
19+
//Instantiating a Workbook object
2120
Workbook workbook = new Workbook();
2221

2322
//Obtaining the reference of the first worksheet
2423
WorksheetCollection worksheets = workbook.getWorksheets();
25-
Worksheet sheet = worksheets.get(0);
24+
Worksheet sheet = worksheets.get(0);
2625

2726
//Adding some sample value to cells
2827
Cells cells = sheet.getCells();
2928
Cell cell = cells.get("A1");
3029
cell.setValue(50);
3130
cell = cells.get("A2");
32-
cell. setValue (100);
31+
cell.setValue(100);
3332
cell = cells.get("A3");
3433
cell.setValue(150);
3534
cell = cells.get("B1");
@@ -42,7 +41,7 @@ public static void main(String[] args) throws Exception
4241
ChartCollection charts = sheet.getCharts();
4342

4443
//Adding a chart to the worksheet
45-
int chartIndex = charts.add(ChartType.PYRAMID,5,0,15,5);
44+
int chartIndex = charts.add(ChartType.PYRAMID, 5, 0, 15, 5);
4645
Chart chart = charts.get(chartIndex);
4746

4847
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
@@ -51,9 +50,9 @@ public static void main(String[] args) throws Exception
5150

5251
//Saving the Excel file
5352
workbook.save(dataDir + "book1.out.xls");
54-
53+
5554
// Print message
5655
System.out.println("Workbook with chart is successfully created.");
57-
56+
5857
}
59-
}
58+
}
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,23 @@
55
* is only intended as a supplement to the documentation, and is provided
66
* "as is", without warranty of any kind, either expressed or implied.
77
*/
8-
9-
package programmersguide.asposecells.creatingcharts.chartmanagementfeatures.settingchartsdata.java;
8+
package com.aspose.cells.examples.charts.management;
109

1110
import com.aspose.cells.*;
11+
import com.aspose.cells.examples.Utils;
1212

13-
public class SettingChartsData
14-
{
15-
public static void main(String[] args) throws Exception
16-
{
13+
public class SettingChartsData {
14+
15+
public static void main(String[] args) throws Exception {
1716
// The path to the documents directory.
18-
String dataDir = "src/programmersguide/asposecells/creatingcharts/chartmanagementfeatures/settingchartsdata/data/";
19-
17+
String dataDir = Utils.getDataDir(SettingChartsData.class);
18+
2019
//Instantiating a Workbook object
2120
Workbook workbook = new Workbook();
2221
WorksheetCollection worksheets = workbook.getWorksheets();
2322

2423
//Obtaining the reference of the first worksheet
25-
Worksheet worksheet= worksheets.get(0);
24+
Worksheet worksheet = worksheets.get(0);
2625
Cells cells = worksheet.getCells();
2726

2827
//Adding a sample value to "A1" cell
@@ -65,19 +64,19 @@ public static void main(String[] args) throws Exception
6564
ChartCollection charts = worksheet.getCharts();
6665

6766
//Accessing the instance of the newly added chart
68-
int chartIndex = charts.add(ChartType.COLUMN,5,0,15,5);
67+
int chartIndex = charts.add(ChartType.COLUMN, 5, 0, 15, 5);
6968
Chart chart = charts.get(chartIndex);
7069

7170
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
7271
SeriesCollection nSeries = chart.getNSeries();
73-
nSeries.add("A1:B4",true);
72+
nSeries.add("A1:B4", true);
7473

7574
//Setting the data source for the category data of NSeries
7675
nSeries.setCategoryData("C1:C4");
7776

7877
workbook.save(dataDir + "book1.out.xls");
79-
80-
// Print message
78+
79+
// Print message
8180
System.out.println("Workbook with chart is created successfully.");
8281
}
83-
}
82+
}
Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
* is only intended as a supplement to the documentation, and is provided
66
* "as is", without warranty of any kind, either expressed or implied.
77
*/
8-
9-
package programmersguide.asposecells.workingwithdata.addonfeatures.addinghyperlinkstolinkdata.addinglinktoanothercell.java;
8+
package com.aspose.cells.examples.data.addon.hyperlinks;
109

1110
import com.aspose.cells.*;
11+
import com.aspose.cells.examples.Utils;
1212

13-
public class AddingLinkToAnotherCell
14-
{
15-
public static void main(String[] args) throws Exception
16-
{
13+
public class AddingLinkToAnotherCell {
14+
15+
public static void main(String[] args) throws Exception {
1716
// The path to the documents directory.
18-
String dataDir = "src/programmersguide/asposecells/workingwithdata/addonfeatures/addinghyperlinkstolinkdata/addinglinktoanothercell/data/";
17+
String dataDir = Utils.getDataDir(AddingLinkToAnotherCell.class);
1918

2019
//Instantiating a Workbook object
2120
Workbook workbook = new Workbook();
@@ -42,7 +41,7 @@ public static void main(String[] args) throws Exception
4241

4342
//Adding an internal hyperlink to the "B9" cell of the other worksheet "Sheet2" in
4443
//the same Excel file
45-
hyperlinks.add("B3",1 ,1, "Sheet2!B9");
44+
hyperlinks.add("B3", 1, 1, "Sheet2!B9");
4645

4746
//Saving the Excel file
4847
workbook.save(dataDir + "output.xls");
@@ -52,7 +51,3 @@ public static void main(String[] args) throws Exception
5251

5352
}
5453
}
55-
56-
57-
58-
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
* is only intended as a supplement to the documentation, and is provided
66
* "as is", without warranty of any kind, either expressed or implied.
77
*/
8-
9-
package programmersguide.asposecells.workingwithdata.addonfeatures.addinghyperlinkstolinkdata.addinglinktoexternalfile.java;
8+
package com.aspose.cells.examples.data.addon.hyperlinks;
109

1110
import com.aspose.cells.*;
11+
import com.aspose.cells.examples.Utils;
1212

13-
public class AddingLinkToExternalFile
14-
{
15-
public static void main(String[] args) throws Exception
16-
{
13+
public class AddingLinkToExternalFile {
14+
15+
public static void main(String[] args) throws Exception {
1716
// The path to the documents directory.
18-
String dataDir = "src/programmersguide/asposecells/workingwithdata/addonfeatures/addinghyperlinkstolinkdata/addinglinktoexternalfile/data/";
17+
String dataDir = Utils.getDataDir(AddingLinkToExternalFile.class);
1918

2019
//Instantiating a Workbook object
2120
Workbook workbook = new Workbook();
@@ -50,7 +49,3 @@ public static void main(String[] args) throws Exception
5049

5150
}
5251
}
53-
54-
55-
56-
Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
* is only intended as a supplement to the documentation, and is provided
66
* "as is", without warranty of any kind, either expressed or implied.
77
*/
8-
9-
package programmersguide.asposecells.workingwithdata.addonfeatures.addinghyperlinkstolinkdata.addinglinktourl.java;
8+
package com.aspose.cells.examples.data.addon.hyperlinks;
109

1110
import com.aspose.cells.*;
11+
import com.aspose.cells.examples.Utils;
1212

13-
public class AddingLinkToURL
14-
{
15-
public static void main(String[] args) throws Exception
16-
{
13+
public class AddingLinkToURL {
14+
15+
public static void main(String[] args) throws Exception {
1716
// The path to the documents directory.
18-
String dataDir = "src/programmersguide/asposecells/workingwithdata/addonfeatures/addinghyperlinkstolinkdata/addinglinktourl/data/";
17+
String dataDir = Utils.getDataDir(AddingLinkToURL.class);
1918

2019
//Instantiating a Workbook object
2120
Workbook workbook = new Workbook();
@@ -26,7 +25,7 @@ public static void main(String[] args) throws Exception
2625
HyperlinkCollection hyperlinks = sheet.getHyperlinks();
2726

2827
//Adding a hyperlink to a URL at "A1" cell
29-
hyperlinks.add("A1",1,1,"http://www.aspose.com");
28+
hyperlinks.add("A1", 1, 1, "http://www.aspose.com");
3029

3130
//Saving the Excel file
3231
workbook.save(dataDir + "output.xls");
@@ -36,7 +35,3 @@ public static void main(String[] args) throws Exception
3635

3736
}
3837
}
39-
40-
41-
42-
Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55
* is only intended as a supplement to the documentation, and is provided
66
* "as is", without warranty of any kind, either expressed or implied.
77
*/
8-
9-
package programmersguide.asposecells.workingwithdata.addonfeatures.mergingunmergingcells.mergingcellsinworksheet.java;
8+
package com.aspose.cells.examples.data.addon.merging;
109

1110
import com.aspose.cells.*;
11+
import com.aspose.cells.examples.Utils;
1212

13-
public class MergingCellsInWorksheet
14-
{
15-
public static void main(String[] args) throws Exception
16-
{
13+
public class MergingCellsInWorksheet {
14+
15+
public static void main(String[] args) throws Exception {
1716
// The path to the documents directory.
18-
String dataDir = "src/programmersguide/asposecells/workingwithdata/addonfeatures/mergingunmergingcells/mergingcellsinworksheet/data/";
17+
String dataDir = Utils.getDataDir(MergingCellsInWorksheet.class);
1918

2019
//Create a Workbook.
21-
Workbook wbk=new Workbook();
20+
Workbook wbk = new Workbook();
2221

2322
//Create a Worksheet and get the first sheet.
2423
Worksheet worksheet = wbk.getWorksheets().get(0);
@@ -27,13 +26,13 @@ public static void main(String[] args) throws Exception
2726
Cells cells = worksheet.getCells();
2827

2928
//Merge some Cells (C6:E7) into a single C6 Cell.
30-
cells.merge(5,2,2,3);
29+
cells.merge(5, 2, 2, 3);
3130

3231
//Input data into C6 Cell.
33-
worksheet.getCells().get(5,2).setValue("This is my value");
32+
worksheet.getCells().get(5, 2).setValue("This is my value");
3433

3534
//Create a Style object to fetch the Style of C6 Cell.
36-
Style style = worksheet.getCells().get(5,2).getStyle();
35+
Style style = worksheet.getCells().get(5, 2).getStyle();
3736

3837
//Create a Font object
3938
Font font = style.getFont();
@@ -58,7 +57,7 @@ public static void main(String[] args) throws Exception
5857
style.setPattern(BackgroundType.SOLID);
5958

6059
//Apply the Style to C6 Cell.
61-
cells.get(5,2).setStyle(style);
60+
cells.get(5, 2).setStyle(style);
6261

6362
//Save the Workbook.
6463
wbk.save(dataDir + "mergingcells.xls");
@@ -67,7 +66,3 @@ public static void main(String[] args) throws Exception
6766
System.out.println("Process completed successfully");
6867
}
6968
}
70-
71-
72-
73-

0 commit comments

Comments
 (0)