-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from shoaibkhan-aspose/master
Aspose.Cells vs Apache POI SS (HSSF + XSSF) - v1.5
- Loading branch information
Showing
223 changed files
with
4,851 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
785 changes: 785 additions & 0 deletions
785
Plugins/Aspose_Cells_for_Apache_POI/Aspose-Cells-for-Apache-POI/Examples.xml
Large diffs are not rendered by default.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
Plugins/Aspose_Cells_for_Apache_POI/Aspose-Cells-for-Apache-POI/LICENSE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Aspose | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
Binary file added
BIN
+23.5 KB
...-for-Apache-POI/src/asposefeatures/datahandlingfeatures/calculatesubtotals/data/book1.xls
Binary file not shown.
38 changes: 38 additions & 0 deletions
38
...rc/asposefeatures/datahandlingfeatures/calculatesubtotals/java/AsposeCreateSubTotals.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
105 changes: 105 additions & 0 deletions
105
...src/asposefeatures/datahandlingfeatures/createpivottable/java/AsposeCreatePivotTable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 added
BIN
+22.5 KB
...he-POI/src/asposefeatures/datahandlingfeatures/exportdatafromworksheets/data/workbook.xls
Binary file not shown.
35 changes: 35 additions & 0 deletions
35
...features/datahandlingfeatures/exportdatafromworksheets/java/ExportDataFromWorksheets.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 added
BIN
+22.5 KB
...for-Apache-POI/src/asposefeatures/datahandlingfeatures/findvalueincells/data/workbook.xls
Binary file not shown.
36 changes: 36 additions & 0 deletions
36
.../asposefeatures/datahandlingfeatures/findvalueincells/java/AsposeFindCellsWithString.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...es/datahandlingfeatures/formulacalculationengine/java/AsposeFormulaCalculationEngine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...posefeatures/datahandlingfeatures/importdatatoworksheets/java/ImportDataToWorksheets.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 added
BIN
+19.5 KB
...-for-Apache-POI/src/asposefeatures/datahandlingfeatures/sortdata/data/AsposeDataInput.xls
Binary file not shown.
59 changes: 59 additions & 0 deletions
59
...-for-Apache-POI/src/asposefeatures/datahandlingfeatures/sortdata/java/AsposeDataSort.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 added
BIN
+22.5 KB
.../src/asposefeatures/datahandlingfeatures/tracingprecedentsanddependents/data/workbook.xls
Binary file not shown.
Oops, something went wrong.