Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ Out*/
*.lic
Data/*Out*
.idea/
pom.xml
26 changes: 26 additions & 0 deletions Examples/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.aspose</groupId>
<artifactId>cells-java-examples</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cells</artifactId>
<version>8.4.2</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>aspose-maven-repository</id>
<url>http://maven.aspose.com/repository/repo/</url>
</repository>
</repositories>
</project>
20 changes: 20 additions & 0 deletions Examples/src/main/java/com/aspose/cells/examples/Utils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.aspose.cells.examples;

import java.io.File;

public class Utils {

public static String getDataDir(Class c) {
File dir = new File(System.getProperty("user.dir"));
dir = new File(dir, "src");
dir = new File(dir, "main");
dir = new File(dir, "resources");

for (String s : c.getName().split("\\.")) {
dir = new File(dir, s);
}

System.out.println("Using data directory: " + dir.toString());
return dir.toString() + File.separator;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
* is only intended as a supplement to the documentation, and is provided
* "as is", without warranty of any kind, either expressed or implied.
*/

package programmersguide.asposecells.creatingcharts.fundamentalfeatures.changechartpositionandsize.java;
package com.aspose.cells.examples.charts.fundamental;

import com.aspose.cells.*;
import com.aspose.cells.examples.Utils;

public class ChangeChartPositionAndSize
{
public static void main(String[] args) throws Exception
{
public class ChangeChartPositionAndSize {

public static void main(String[] args) throws Exception {
// The path to the documents directory.
String dataDir = "src/programmersguide/asposecells/creatingcharts/fundamentalfeatures/changechartpositionandsize/data/";
String dataDir = Utils.getDataDir(ChangeChartPositionAndSize.class);

String filePath = dataDir + "book1.xls";

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

//Output the file
workbook.save(dataDir + "book1.out.xls");

// Print message
System.out.println("Position and Size of Chart is changed successfully.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,30 @@
* is only intended as a supplement to the documentation, and is provided
* "as is", without warranty of any kind, either expressed or implied.
*/

package programmersguide.asposecells.creatingcharts.fundamentalfeatures.createchart.java;
package com.aspose.cells.examples.charts.fundamental;

import com.aspose.cells.*;
import com.aspose.cells.examples.Utils;

public class CreateChart
{
public static void main(String[] args) throws Exception
{
public class CreateChart {

public static void main(String[] args) throws Exception {
// The path to the documents directory.
String dataDir = "src/programmersguide/asposecells/creatingcharts/fundamentalfeatures/createchart/data/";
//Instantiating a Workbook object
String dataDir = Utils.getDataDir(CreateChart.class);

//Instantiating a Workbook object
Workbook workbook = new Workbook();

//Obtaining the reference of the first worksheet
WorksheetCollection worksheets = workbook.getWorksheets();
Worksheet sheet = worksheets.get(0);
Worksheet sheet = worksheets.get(0);

//Adding some sample value to cells
Cells cells = sheet.getCells();
Cell cell = cells.get("A1");
cell.setValue(50);
cell = cells.get("A2");
cell. setValue (100);
cell.setValue(100);
cell = cells.get("A3");
cell.setValue(150);
cell = cells.get("B1");
Expand All @@ -42,7 +41,7 @@ public static void main(String[] args) throws Exception
ChartCollection charts = sheet.getCharts();

//Adding a chart to the worksheet
int chartIndex = charts.add(ChartType.PYRAMID,5,0,15,5);
int chartIndex = charts.add(ChartType.PYRAMID, 5, 0, 15, 5);
Chart chart = charts.get(chartIndex);

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

//Saving the Excel file
workbook.save(dataDir + "book1.out.xls");

// Print message
System.out.println("Workbook with chart is successfully created.");

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,23 @@
* is only intended as a supplement to the documentation, and is provided
* "as is", without warranty of any kind, either expressed or implied.
*/

package programmersguide.asposecells.creatingcharts.chartmanagementfeatures.settingchartsdata.java;
package com.aspose.cells.examples.charts.management;

import com.aspose.cells.*;
import com.aspose.cells.examples.Utils;

public class SettingChartsData
{
public static void main(String[] args) throws Exception
{
public class SettingChartsData {

public static void main(String[] args) throws Exception {
// The path to the documents directory.
String dataDir = "src/programmersguide/asposecells/creatingcharts/chartmanagementfeatures/settingchartsdata/data/";
String dataDir = Utils.getDataDir(SettingChartsData.class);

//Instantiating a Workbook object
Workbook workbook = new Workbook();
WorksheetCollection worksheets = workbook.getWorksheets();

//Obtaining the reference of the first worksheet
Worksheet worksheet= worksheets.get(0);
Worksheet worksheet = worksheets.get(0);
Cells cells = worksheet.getCells();

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

//Accessing the instance of the newly added chart
int chartIndex = charts.add(ChartType.COLUMN,5,0,15,5);
int chartIndex = charts.add(ChartType.COLUMN, 5, 0, 15, 5);
Chart chart = charts.get(chartIndex);

//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
SeriesCollection nSeries = chart.getNSeries();
nSeries.add("A1:B4",true);
nSeries.add("A1:B4", true);

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

workbook.save(dataDir + "book1.out.xls");
// Print message

// Print message
System.out.println("Workbook with chart is created successfully.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
* is only intended as a supplement to the documentation, and is provided
* "as is", without warranty of any kind, either expressed or implied.
*/

package programmersguide.asposecells.workingwithdata.addonfeatures.addinghyperlinkstolinkdata.addinglinktoanothercell.java;
package com.aspose.cells.examples.data.addon.hyperlinks;

import com.aspose.cells.*;
import com.aspose.cells.examples.Utils;

public class AddingLinkToAnotherCell
{
public static void main(String[] args) throws Exception
{
public class AddingLinkToAnotherCell {

public static void main(String[] args) throws Exception {
// The path to the documents directory.
String dataDir = "src/programmersguide/asposecells/workingwithdata/addonfeatures/addinghyperlinkstolinkdata/addinglinktoanothercell/data/";
String dataDir = Utils.getDataDir(AddingLinkToAnotherCell.class);

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

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

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

}
}




Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
* is only intended as a supplement to the documentation, and is provided
* "as is", without warranty of any kind, either expressed or implied.
*/

package programmersguide.asposecells.workingwithdata.addonfeatures.addinghyperlinkstolinkdata.addinglinktoexternalfile.java;
package com.aspose.cells.examples.data.addon.hyperlinks;

import com.aspose.cells.*;
import com.aspose.cells.examples.Utils;

public class AddingLinkToExternalFile
{
public static void main(String[] args) throws Exception
{
public class AddingLinkToExternalFile {

public static void main(String[] args) throws Exception {
// The path to the documents directory.
String dataDir = "src/programmersguide/asposecells/workingwithdata/addonfeatures/addinghyperlinkstolinkdata/addinglinktoexternalfile/data/";
String dataDir = Utils.getDataDir(AddingLinkToExternalFile.class);

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

}
}




Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
* is only intended as a supplement to the documentation, and is provided
* "as is", without warranty of any kind, either expressed or implied.
*/

package programmersguide.asposecells.workingwithdata.addonfeatures.addinghyperlinkstolinkdata.addinglinktourl.java;
package com.aspose.cells.examples.data.addon.hyperlinks;

import com.aspose.cells.*;
import com.aspose.cells.examples.Utils;

public class AddingLinkToURL
{
public static void main(String[] args) throws Exception
{
public class AddingLinkToURL {

public static void main(String[] args) throws Exception {
// The path to the documents directory.
String dataDir = "src/programmersguide/asposecells/workingwithdata/addonfeatures/addinghyperlinkstolinkdata/addinglinktourl/data/";
String dataDir = Utils.getDataDir(AddingLinkToURL.class);

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

//Adding a hyperlink to a URL at "A1" cell
hyperlinks.add("A1",1,1,"http://www.aspose.com");
hyperlinks.add("A1", 1, 1, "http://www.aspose.com");

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

}
}




Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
* is only intended as a supplement to the documentation, and is provided
* "as is", without warranty of any kind, either expressed or implied.
*/

package programmersguide.asposecells.workingwithdata.addonfeatures.mergingunmergingcells.mergingcellsinworksheet.java;
package com.aspose.cells.examples.data.addon.merging;

import com.aspose.cells.*;
import com.aspose.cells.examples.Utils;

public class MergingCellsInWorksheet
{
public static void main(String[] args) throws Exception
{
public class MergingCellsInWorksheet {

public static void main(String[] args) throws Exception {
// The path to the documents directory.
String dataDir = "src/programmersguide/asposecells/workingwithdata/addonfeatures/mergingunmergingcells/mergingcellsinworksheet/data/";
String dataDir = Utils.getDataDir(MergingCellsInWorksheet.class);

//Create a Workbook.
Workbook wbk=new Workbook();
Workbook wbk = new Workbook();

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

//Merge some Cells (C6:E7) into a single C6 Cell.
cells.merge(5,2,2,3);
cells.merge(5, 2, 2, 3);

//Input data into C6 Cell.
worksheet.getCells().get(5,2).setValue("This is my value");
worksheet.getCells().get(5, 2).setValue("This is my value");

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

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

//Apply the Style to C6 Cell.
cells.get(5,2).setStyle(style);
cells.get(5, 2).setStyle(style);

//Save the Workbook.
wbk.save(dataDir + "mergingcells.xls");
Expand All @@ -67,7 +66,3 @@ public static void main(String[] args) throws Exception
System.out.println("Process completed successfully");
}
}




Loading