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
10 changes: 6 additions & 4 deletions Plugins/Aspose_Cells_for_Apache_POI/.classpath
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="lib" path="D:/Banckle/workspaces/ApachePOI_GitHub/lib/Aspose/aspose-cells-8.3.0.jar"/>
<classpathentry kind="lib" path="D:/Banckle/workspaces/ApachePOI_GitHub/lib/ApachePOI/poi-3.11-beta1-20140306.jar"/>
<classpathentry kind="lib" path="D:/Banckle/workspaces/ApachePOI_GitHub/lib/ApachePOI/poi-ooxml-3.11-beta1-20140306.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="lib" path="/Users/shoaibkhan/Downloads/Aspose/AsposeComponents/aspose-cells-8.3.2-java/JDK 1.6/aspose-cells-8.3.2-java/lib/aspose-cells-8.3.2.jar"/>
<classpathentry kind="lib" path="/Users/shoaibkhan/Downloads/ApachePOI/poi-3.11/poi-3.11-20141221.jar"/>
<classpathentry kind="lib" path="/Users/shoaibkhan/Downloads/ApachePOI/poi-3.11/poi-ooxml-3.11-20141221.jar"/>
<classpathentry kind="lib" path="/Users/shoaibkhan/Downloads/ApachePOI/poi-3.11/poi-ooxml-schemas-3.11-20141221.jar"/>
<classpathentry kind="lib" path="/Users/shoaibkhan/Downloads/ApachePOI/poi-3.11/ooxml-lib/xmlbeans-2.6.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package asposefeatures.datahandlingfeatures.calculatesubtotals.java;

import com.aspose.cells.CellArea;
import com.aspose.cells.Cells;
import com.aspose.cells.ConsolidationFunction;
import com.aspose.cells.Workbook;

public class AsposeCreateSubTotals
{
public static void main(String[] args) throws Exception
{
String dataPath = "src/asposefeatures/datahandlingfeatures/calculatesubtotals/data/";

// Instantiate a new workbook
Workbook workbook = new Workbook(dataPath + "book1.xls");

// Get the Cells collection in the first worksheet
Cells cells = workbook.getWorksheets().get(0).getCells();

// Create a cellarea i.e.., B3:C19
CellArea ca = new CellArea();
ca.StartRow = 2;
ca.StartColumn = 1;
ca.EndRow = 18;
ca.EndColumn = 2;

// Apply subtotal, the consolidation function is Sum and it will applied
// to
// Second column (C) in the list
cells.subtotal(ca, 0, ConsolidationFunction.SUM, new int[] { 1 });

// Save the excel file
workbook.save(dataPath + "AsposeTotal.xls");

// Print message
System.out.println("Process completed successfully");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package asposefeatures.datahandlingfeatures.createpivottable.java;

import com.aspose.cells.Cell;
import com.aspose.cells.Cells;
import com.aspose.cells.PivotFieldType;
import com.aspose.cells.PivotTable;
import com.aspose.cells.PivotTableCollection;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;

public class AsposeCreatePivotTable
{
public static void main(String[] args) throws Exception
{
String dataPath = "src/asposefeatures/datahandlingfeatures/createpivottable/data/";

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

// Obtaining the reference of the newly added worksheet
Worksheet sheet = workbook.getWorksheets().get(0);
sheet.setName("PivotTable");

Cells cells = sheet.getCells();

// Setting the value to the cells
Cell cell = cells.get("A1");
cell.setValue("Sport");
cell = cells.get("B1");
cell.setValue("Quarter");
cell = cells.get("C1");
cell.setValue("Sales");

cell = cells.get("A2");
cell.setValue("Golf");
cell = cells.get("A3");
cell.setValue("Golf");
cell = cells.get("A4");
cell.setValue("Tennis");
cell = cells.get("A5");
cell.setValue("Tennis");
cell = cells.get("A6");
cell.setValue("Tennis");
cell = cells.get("A7");
cell.setValue("Tennis");
cell = cells.get("A8");
cell.setValue("Golf");

cell = cells.get("B2");
cell.setValue("Qtr3");
cell = cells.get("B3");
cell.setValue("Qtr4");
cell = cells.get("B4");
cell.setValue("Qtr3");
cell = cells.get("B5");
cell.setValue("Qtr4");
cell = cells.get("B6");
cell.setValue("Qtr3");
cell = cells.get("B7");
cell.setValue("Qtr4");
cell = cells.get("B8");
cell.setValue("Qtr3");

cell = cells.get("C2");
cell.setValue(1500);
cell = cells.get("C3");
cell.setValue(2000);
cell = cells.get("C4");
cell.setValue(600);
cell = cells.get("C5");
cell.setValue(1500);
cell = cells.get("C6");
cell.setValue(4070);
cell = cells.get("C7");
cell.setValue(5000);
cell = cells.get("C8");
cell.setValue(6430);

PivotTableCollection pivotTables = sheet.getPivotTables();

// Adding a PivotTable to the worksheet
int index = pivotTables.add("=A1:C8", "E3", "PivotTable1");

// Accessing the instance of the newly added PivotTable
PivotTable pivotTable = pivotTables.get(index);

// Unshowing grand totals for rows.
pivotTable.setRowGrand(false);

// Dragging the first field to the row area.
pivotTable.addFieldToArea(PivotFieldType.ROW, 0);

// Dragging the second field to the column area.
pivotTable.addFieldToArea(PivotFieldType.COLUMN, 1);

// Dragging the third field to the data area.
pivotTable.addFieldToArea(PivotFieldType.DATA, 2);

// Saving the Excel file
workbook.save(dataPath + "AsposePivotTable.xls");

// Print Message
System.out.println("Pivot Table created successfully.");
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package asposefeatures.datahandlingfeatures.exportdatafromworksheets.java;

import java.io.FileInputStream;
import java.util.Arrays;

import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;

public class ExportDataFromWorksheets
{
public static void main(String[] args) throws Exception
{
String dataPath = "src/asposefeatures/datahandlingfeatures/exportdatafromworksheets/data/";

// Creating a file stream containing the Excel file to be opened
FileInputStream fstream = new FileInputStream(dataPath + "workbook.xls");

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

// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.getWorksheets().get(0);

// Exporting the contents of 7 rows and 2 columns starting from 1st cell
// to Array.
Object dataTable[][] = worksheet.getCells().exportArray(4, 0, 7, 8);

for (int i = 0; i < dataTable.length; i++)
{
System.out.println("[" + i + "]: " + Arrays.toString(dataTable[i]));
}
// Closing the file stream to free all resources
fstream.close();
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package asposefeatures.datahandlingfeatures.findvalueincells.java;

import com.aspose.cells.Cell;
import com.aspose.cells.Cells;
import com.aspose.cells.FindOptions;
import com.aspose.cells.LookAtType;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;

public class AsposeFindCellsWithString
{
public static void main(String[] args) throws Exception
{
String dataPath = "src/asposefeatures/datahandlingfeatures/findvalueincells/data/";

// Instantiating a Workbook object
Workbook workbook = new Workbook(dataPath + "workbook.xls");

// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.getWorksheets().get(0);

// Finding the cell containing the specified formula
Cells cells = worksheet.getCells();

// Instantiate FindOptions
FindOptions findOptions = new FindOptions();

// Finding the cell containing a string value that starts with "Or"
findOptions.setLookAtType(LookAtType.START_WITH);

Cell cell = cells.find("SH", null, findOptions);

// Printing the name of the cell found after searching worksheet
System.out.println("Name of the cell containing String: " + cell.getName());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package asposefeatures.datahandlingfeatures.formulacalculationengine.java;

import com.aspose.cells.Cell;
import com.aspose.cells.Cells;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;

public class AsposeFormulaCalculationEngine
{
public static void main(String[] args) throws Exception
{
String dataPath = "src/asposefeatures/datahandlingfeatures/formulacalculationengine/data/";

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

// Obtaining the reference of the newly added worksheet
int sheetIndex = book.getWorksheets().add();
Worksheet worksheet = book.getWorksheets().get(sheetIndex);
Cells cells = worksheet.getCells();
Cell cell = null;

// Adding a value to "A1" cell
cell = cells.get("A1");
cell.setValue(1);

// Adding a value to "A2" cell
cell = cells.get("A2");
cell.setValue(2);

// Adding a value to "A3" cell
cell = cells.get("A3");
cell.setValue(3);

// Adding a SUM formula to "A4" cell
cell = cells.get("A4");
cell.setFormula("=SUM(A1:A3)");

// Calculating the results of formulas
book.calculateFormula();

// Saving the Excel file
book.save(dataPath + "AsposeFormulaEngine.xls");
System.out.println("Done.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package asposefeatures.datahandlingfeatures.importdatatoworksheets.java;

import java.util.ArrayList;

import com.aspose.cells.Cells;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;

public class ImportDataToWorksheets
{
public static void main(String[] args) throws Exception
{
String dataPath = "src/asposefeatures/datahandlingfeatures/importdatatoworksheets/data/";

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

// Obtaining the reference of the newly added worksheet by passing its
// sheet index
int sheetIndex = workbook.getWorksheets().add();
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex);

// ==================================================
// Creating an array containing names as string values
String[] names = new String[] { "laurence chen", "roman korchagin", "kyle huang" };

// Importing the array of names to 1st row and first column vertically
Cells cells = worksheet.getCells();
cells.importArray(names, 0, 0, false);

// ==================================================
ArrayList<String> list = new ArrayList<String>();

// Add few names to the list as string values
list.add("laurence chen");
list.add("roman korchagin");
list.add("kyle huang");

// Importing the contents of ArrayList to 1st row and first column
// vertically
cells.importArrayList(list, 2, 0, true);
// ==================================================

// Saving the Excel file
workbook.save(dataPath + "AsposeDataImport.xls");
System.out.println("Done.");
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package asposefeatures.datahandlingfeatures.sortdata.java;

import com.aspose.cells.CellArea;
import com.aspose.cells.Cells;
import com.aspose.cells.DataSorter;
import com.aspose.cells.SortOrder;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;

public class AsposeDataSort
{
public static void main(String[] args) throws Exception
{
String dataPath = "src/asposefeatures/datahandlingfeatures/sortdata/data/";

// Instantiating a Workbook object
Workbook workbook = new Workbook(dataPath + "AsposeDataInput.xls");

// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.getWorksheets().get(0);

// Get the cells collection in the sheet
Cells cells = worksheet.getCells();

// Obtain the DataSorter object in the workbook
DataSorter sorter = workbook.getDataSorter();

// Set the first order
sorter.setOrder1(SortOrder.ASCENDING);

// Define the first key.
sorter.setKey1(0);

// Set the second order
sorter.setOrder2(SortOrder.ASCENDING);

// Define the second key
sorter.setKey2(1);

// Create a cells area (range).
CellArea ca = new CellArea();

// Specify the start row index.
ca.StartRow = 1;
// Specify the start column index.
ca.StartColumn = 0;
// Specify the last row index.
ca.EndRow = 9;
// Specify the last column index.
ca.EndColumn = 2;

// Sort data in the specified data range (A2:C10)
sorter.sort(cells, ca);

// Saving the excel file
workbook.save(dataPath + "AsposeSortedData.xls");
System.out.println("Done.");
}
}
Binary file not shown.
Loading