diff --git a/Plugins/Aspose_Cells_for_Apache_POI/.classpath b/Plugins/Aspose_Cells_for_Apache_POI/.classpath new file mode 100644 index 00000000..5abc004d --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Plugins/Aspose_Cells_for_Apache_POI/.project b/Plugins/Aspose_Cells_for_Apache_POI/.project new file mode 100644 index 00000000..33ab5707 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/.project @@ -0,0 +1,17 @@ + + + Aspose_Cells_for_ApachePOI + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Plugins/Aspose_Cells_for_Apache_POI/Examples.xml b/Plugins/Aspose_Cells_for_Apache_POI/Examples.xml new file mode 100644 index 00000000..02453a88 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/Examples.xml @@ -0,0 +1,285 @@ + + + + + Features Comparison + +Contain the code comparison for features in Apache POI SS SDK and Aspose.Cells +These examples are helpful for developers who want to compare Apache POI with Aspose OR migrate from Apache POI to Aspose. + + featurescomparison + 1 + + + Working with Workbook + This folder contain the examples to deal with Workbooks. + workingwithworkbook + 1 + + + Create New Workbook + How to create new Workbook. + createnewworkbook + 1 + + + ..\data\newWorkBook_Aspose_Out.xlsx + + + ..\data\newWorkBook_Apache_Out.xls + + + Console + + + Add Data in Cells + How to add data in cells. + adddataincells + 2 + + + ..\data\DataInCells_Aspose_Out.xls + + + ..\data\DataInCells_Apache_Out.xls + + + Console + + + Set Print Area + How to Set Print Area. + setprintarea + 3 + + + ..\data\AsposePrintArea_Out.xlsx + + + ..\data\ApachePrintArea_Out.xls + + + Console + + + + + Working with Worksheets + This folder contain the examples to deal with worksheets. + workingwithworksheets + 1 + + + Create New Worksheet + How to create new worksheet. + createnewworksheet + 1 + + + ..\data\newWorksheet_Aspose_Out.xls + + + ..\data\newWorksheet_Apache_Out.xls + + + Console + + + Copy Sheet Within Workbook + How to copy sheets with in workbook. + copysheetwithinworkbook + 2 + + + ..\data\AsposeCopyWorkbook_Out.xls + + + Console + + + Re-Order Sheets Within Workbook + How to re-order sheets (change sequence number of sheet) with in workbook. + reordersheetswithinworkbook + 3 + + + ..\data\AsposeMoveSheet_Out.xls + + + ..\data\Apache_Reordered_Out.xls + + + Console + + + Zoom Factor + How to set zoom value for worksheet + zoomfactor + 4 + + + ..\data\AsposeZoom_Out.xls + + + ..\data\ApacheZoom_Out.xls + + + Console + + + Header and Footers + Working wih header and footers + headerandfooter + 5 + + + ..\data\footer.png + + + + + ..\data\AsposeHeaderFooter_Out.xls + + + ..\data\ApacheHeaderFooter_Out.xls + + + Console + + + + + Working with Cells, Rows and Columns + This folder contain the examples to deal with Cells, Rows and Columns. + workingwithcellsrowscolumns + 1 + + + Freeze Panes + How to freeze desired Rows and Columns + freezepanes + 1 + + + ..\data\workbook_Aspose_Out.xls + + + ..\data\workbook_Apache_Out.xls + + + Console + + + Hide and Unhide Cells + Shows how to hide and unhide specific Cells + hideunhidecells + 2 + + + ..\data\workbook.xls + + + + + ..\data\hideUnhideCells_Aspose_Out.xls + + + ..\data\hideUnhideCells_Apache_Out.xls + + + Console + + + Merge Cells + How to merge multiple Cells + mergecells + 3 + + + ..\data\merge_Aspose_Out.xls + + + ..\data\merge_Apache_Out.xls + + + Console + + + Auto Fit Row and Column + Adjust the size of rows and column by autofit + autofitrowandcolumn + 4 + + + ..\data\workbook.xls + + + + + ..\data\AutoFit_Aspose_Out.xls + + + ..\data\AutoFit_Apache_Out.xls + + + Console + + + + + Working with Formatting Features + This folder contain the examples to deal with documents. + workingwithformattingfeatures + 1 + + + Working with Fonts + How to use font options + workingwithfonts + 1 + + + ..\data\AsposeFonts.xls + + + ..\data\ApacheFonts.xls + + + Console + + + Working with Colors + How to different colors + workingwithcolors + 2 + + + ..\data\AsposeColors_Out.xls + + + ..\data\ApacheColors_Out.xls + + + Console + + + Working with Borders + How to apply border options + workingwithborders + 3 + + + ..\data\AsposeBorders_Out.xls + + + ..\data\ApacheBorders_Out.xls + + + Console + + + + + + + \ No newline at end of file diff --git a/Plugins/Aspose_Cells_for_Apache_POI/LICENSE b/Plugins/Aspose_Cells_for_Apache_POI/LICENSE new file mode 100644 index 00000000..42c0c48c --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2014 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. + diff --git a/Plugins/Aspose_Cells_for_Apache_POI/README.md b/Plugins/Aspose_Cells_for_Apache_POI/README.md new file mode 100644 index 00000000..6ffda1cb --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/README.md @@ -0,0 +1,2 @@ +Project in Development Phase +============================= diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/autofitrowandcolumn/data/workbook.xls b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/autofitrowandcolumn/data/workbook.xls new file mode 100644 index 00000000..900bbb04 Binary files /dev/null and b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/autofitrowandcolumn/data/workbook.xls differ diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/autofitrowandcolumn/java/ApacheAutoFit.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/autofitrowandcolumn/java/ApacheAutoFit.java new file mode 100644 index 00000000..2eda7490 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/autofitrowandcolumn/java/ApacheAutoFit.java @@ -0,0 +1,31 @@ +package featurescomparison.workingwithcellsrowscolumns.autofitrowandcolumn.java; + +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; + +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; + +public class ApacheAutoFit +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithcellsrowscolumns/autofitrowandcolumn/data/"; + + InputStream inStream = new FileInputStream(dataPath + "workbook.xls"); + Workbook workbook = WorkbookFactory.create(inStream); + + Sheet sheet = workbook.createSheet("new sheet"); + sheet.autoSizeColumn(0); //adjust width of the first column + sheet.autoSizeColumn(1); //adjust width of the second column + + FileOutputStream fileOut; + fileOut = new FileOutputStream(dataPath + "AutoFit_Apache_Out.xls"); + workbook.write(fileOut); + fileOut.close(); + + System.out.println("Process Completed."); + } +} \ No newline at end of file diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/autofitrowandcolumn/java/AsposeAutoFit.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/autofitrowandcolumn/java/AsposeAutoFit.java new file mode 100644 index 00000000..20fd0d62 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/autofitrowandcolumn/java/AsposeAutoFit.java @@ -0,0 +1,28 @@ +package featurescomparison.workingwithcellsrowscolumns.autofitrowandcolumn.java; + +import com.aspose.cells.Workbook; +import com.aspose.cells.Worksheet; + +public class AsposeAutoFit +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithcellsrowscolumns/autofitrowandcolumn/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); + + worksheet.autoFitRow(1); //Auto-fitting the 2nd row of the worksheet + worksheet.autoFitColumn(0); //Auto-fitting the 1st column of the worksheet + + //Saving the modified Excel file in default (that is Excel 2003) format + workbook.save(dataPath + "AutoFit_Aspose_Out.xls"); + + //Print message + System.out.println("Row and Column auto fit successfully."); + + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/freezepanes/java/ApacheFreezePanes.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/freezepanes/java/ApacheFreezePanes.java new file mode 100644 index 00000000..290f5ac3 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/freezepanes/java/ApacheFreezePanes.java @@ -0,0 +1,34 @@ +package featurescomparison.workingwithcellsrowscolumns.freezepanes.java; + +import java.io.FileOutputStream; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; + +public class ApacheFreezePanes +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithcellsrowscolumns/freezepanes/data/"; + + Workbook wb = new HSSFWorkbook(); + Sheet sheet1 = wb.createSheet("new sheet"); + Sheet sheet2 = wb.createSheet("second sheet"); + Sheet sheet3 = wb.createSheet("third sheet"); + + // Freeze just one row + sheet1.createFreezePane( 0, 2, 0, 2 ); + // Freeze just one column + sheet2.createFreezePane( 2, 0, 2, 0 ); + // Freeze the columns and rows (forget about scrolling position of the lower right quadrant). + sheet3.createFreezePane( 2, 2 ); + + FileOutputStream fileOut = new FileOutputStream(dataPath + "workbook_Apache_Out.xls"); + wb.write(fileOut); + fileOut.close(); + + //Print Message + System.out.println("Panes freeze successfull."); + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/freezepanes/java/AsposeFreezePanes.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/freezepanes/java/AsposeFreezePanes.java new file mode 100644 index 00000000..7c7c8a98 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/freezepanes/java/AsposeFreezePanes.java @@ -0,0 +1,32 @@ +package featurescomparison.workingwithcellsrowscolumns.freezepanes.java; + +import com.aspose.cells.Workbook; +import com.aspose.cells.Worksheet; +import com.aspose.cells.WorksheetCollection; + +public class AsposeFreezePanes +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithcellsrowscolumns/freezepanes/data/"; + + //Instantiating a Excel object by excel file path + Workbook workbook = new Workbook(); + + //Accessing the first worksheet in the Excel file + WorksheetCollection worksheets = workbook.getWorksheets(); + + Worksheet worksheet1 = worksheets.get(0); + Worksheet worksheet2 = worksheets.add("Sheet2"); + + //Applying freeze panes settings + worksheet1.freezePanes(0,2,0,2); // Freezing Columns + worksheet2.freezePanes(2,0,2,0); // Freezing Rows + + //Saving the modified Excel file in default format + workbook.save(dataPath + "workbook_Aspose_Out.xls"); + + //Print Message + System.out.println("Panes freeze successfull."); + } +} \ No newline at end of file diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/hideunhidecells/data/workbook.xls b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/hideunhidecells/data/workbook.xls new file mode 100644 index 00000000..848de331 Binary files /dev/null and b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/hideunhidecells/data/workbook.xls differ diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/hideunhidecells/java/ApacheHideUnHideCells.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/hideunhidecells/java/ApacheHideUnHideCells.java new file mode 100644 index 00000000..c21256f8 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/hideunhidecells/java/ApacheHideUnHideCells.java @@ -0,0 +1,30 @@ +package featurescomparison.workingwithcellsrowscolumns.hideunhidecells.java; + +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; + +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; + +public class ApacheHideUnHideCells +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithcellsrowscolumns/hideunhidecells/data/"; + + InputStream inStream = new FileInputStream(dataPath + "workbook.xls"); + Workbook workbook = WorkbookFactory.create(inStream); + Sheet sheet = workbook.createSheet(); + Row row = sheet.createRow(0); + row.setZeroHeight(true); + + FileOutputStream fileOut = new FileOutputStream(dataPath + "hideUnhideCells_Apache_Out.xls"); + workbook.write(fileOut); + fileOut.close(); + + System.out.println("Process Completed."); + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/hideunhidecells/java/AsposeHideUnHideCells.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/hideunhidecells/java/AsposeHideUnHideCells.java new file mode 100644 index 00000000..92368af6 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/hideunhidecells/java/AsposeHideUnHideCells.java @@ -0,0 +1,29 @@ +package featurescomparison.workingwithcellsrowscolumns.hideunhidecells.java; + +import com.aspose.cells.Cells; +import com.aspose.cells.Workbook; +import com.aspose.cells.Worksheet; + +public class AsposeHideUnHideCells +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithcellsrowscolumns/hideunhidecells/data/"; + + Workbook workbook = new Workbook(dataPath + "workbook.xls"); + + //Accessing the first worksheet in the Excel file + Worksheet worksheet = workbook.getWorksheets().get(0); + Cells cells = worksheet.getCells(); + + cells.hideRow(2); //Hiding the 3rd row of the worksheet + cells.hideColumn(1); //Hiding the 2nd column of the worksheet + + //Saving the modified Excel file in default (that is Excel 2003) format + workbook.save(dataPath + "hideUnhideCells_Aspose_Out.xls"); + + //Print message + System.out.println("Rows and Columns hidden successfully."); + + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/mergecells/java/ApacheMergeCells.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/mergecells/java/ApacheMergeCells.java new file mode 100644 index 00000000..6264c1ea --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/mergecells/java/ApacheMergeCells.java @@ -0,0 +1,40 @@ +package featurescomparison.workingwithcellsrowscolumns.mergecells.java; + +import java.io.FileOutputStream; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.util.CellRangeAddress; + +public class ApacheMergeCells +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithcellsrowscolumns/mergecells/data/"; + + Workbook wb = new HSSFWorkbook(); + Sheet sheet = wb.createSheet("new sheet"); + + Row row = sheet.createRow((short) 1); + Cell cell = row.createCell((short) 1); + cell.setCellValue("This is a test of merging"); + + sheet.addMergedRegion(new CellRangeAddress( + 1, //first row (0-based) + 1, //last row (0-based) + 1, //first column (0-based) + 2 //last column (0-based) + )); + + // Write the output to a file + FileOutputStream fileOut = new FileOutputStream(dataPath + "merge_Apache_Out.xls"); + wb.write(fileOut); + fileOut.close(); + + // Print message + System.out.println("Process completed successfully"); + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/mergecells/java/AsposeMergeCells.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/mergecells/java/AsposeMergeCells.java new file mode 100644 index 00000000..b0d0b84a --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithcellsrowscolumns/mergecells/java/AsposeMergeCells.java @@ -0,0 +1,34 @@ +package featurescomparison.workingwithcellsrowscolumns.mergecells.java; + +import com.aspose.cells.Cells; +import com.aspose.cells.Workbook; +import com.aspose.cells.Worksheet; + +public class AsposeMergeCells +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithcellsrowscolumns/mergecells/data/"; + + //Create a Workbook. + Workbook wbk = new Workbook(); + + //Create a Worksheet and get the first sheet. + Worksheet worksheet = wbk.getWorksheets().get(0); + + //Create a Cells object to fetch all the cells. + Cells cells = worksheet.getCells(); + + //Merge some Cells (C6:E7) into a single C6 Cell. + cells.merge(5,2,2,3); + + //Input data into C6 Cell. + worksheet.getCells().get(5,2).setValue("This is a test of merging"); + + //Save the Workbook. + wbk.save(dataPath + "merge_Aspose_Out.xls"); + + // Print message + System.out.println("Process completed successfully"); + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithformattingfeatures/workingwithborders/java/ApacheBorders.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithformattingfeatures/workingwithborders/java/ApacheBorders.java new file mode 100644 index 00000000..3c41a534 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithformattingfeatures/workingwithborders/java/ApacheBorders.java @@ -0,0 +1,52 @@ +package featurescomparison.workingwithformattingfeatures.workingwithborders.java; + +import java.io.FileOutputStream; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; + +public class ApacheBorders +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithformattingfeatures/workingwithborders/data/"; + + Workbook wb = new HSSFWorkbook(); + Sheet sheet = wb.createSheet("new sheet"); + + // Create a row and put some cells in it. Rows are 0 based. + Row row = sheet.createRow(1); + + // Create a cell and put a value in it. + Cell cell = row.createCell(1); + cell.setCellValue(4); + + // Style the cell with borders all around. + CellStyle style = wb.createCellStyle(); + style.setBorderBottom(CellStyle.BORDER_THIN); + style.setBottomBorderColor(IndexedColors.BLACK.getIndex()); + + style.setBorderLeft(CellStyle.BORDER_THIN); + style.setLeftBorderColor(IndexedColors.GREEN.getIndex()); + + style.setBorderRight(CellStyle.BORDER_THIN); + style.setRightBorderColor(IndexedColors.BLUE.getIndex()); + + style.setBorderTop(CellStyle.BORDER_MEDIUM_DASHED); + style.setTopBorderColor(IndexedColors.BLACK.getIndex()); + + cell.setCellStyle(style); + + // Write the output to a file + FileOutputStream fileOut = new FileOutputStream(dataPath + "ApacheBorders_Out.xls"); + wb.write(fileOut); + fileOut.close(); + + System.out.println("Process Completed."); + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithformattingfeatures/workingwithborders/java/AsposeBorders.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithformattingfeatures/workingwithborders/java/AsposeBorders.java new file mode 100644 index 00000000..eb4e2c07 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithformattingfeatures/workingwithborders/java/AsposeBorders.java @@ -0,0 +1,52 @@ +package featurescomparison.workingwithformattingfeatures.workingwithborders.java; + +import com.aspose.cells.BorderType; +import com.aspose.cells.Cell; +import com.aspose.cells.CellBorderType; +import com.aspose.cells.Cells; +import com.aspose.cells.Color; +import com.aspose.cells.Style; +import com.aspose.cells.Workbook; +import com.aspose.cells.Worksheet; + +public class AsposeBorders +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithformattingfeatures/workingwithborders/data/"; + + //Instantiating a Workbook object + Workbook workbook = new Workbook(); + + //Accessing the worksheet in the Excel file + Worksheet worksheet = workbook.getWorksheets().get(0); + Cells cells = worksheet.getCells(); + + //Accessing the "A1" cell from the worksheet + Cell cell = cells.get("B2"); + + //Adding some value to the "A1" cell + cell.setValue("Visit Aspose @ www.aspose.com!"); + Style style = cell.getStyle(); + + //Setting the line of the top border + style.setBorder(BorderType.TOP_BORDER,CellBorderType.THICK,Color.getBlack()); + + //Setting the line of the bottom border + style.setBorder(BorderType.BOTTOM_BORDER,CellBorderType.THICK,Color.getBlack()); + + //Setting the line of the left border + style.setBorder(BorderType.LEFT_BORDER,CellBorderType.THICK,Color.getBlack()); + + //Setting the line of the right border + style.setBorder(BorderType.RIGHT_BORDER,CellBorderType.THICK,Color.getBlack()); + + //Saving the modified style to the "A1" cell. + cell.setStyle(style); + + //Saving the Excel file + workbook.save(dataPath + "AsposeBorders_Out.xls"); + + System.out.println("Aspose Borders Created."); + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithformattingfeatures/workingwithcolors/java/ApacheWorkingWithColors.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithformattingfeatures/workingwithcolors/java/ApacheWorkingWithColors.java new file mode 100644 index 00000000..c80f8683 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithformattingfeatures/workingwithcolors/java/ApacheWorkingWithColors.java @@ -0,0 +1,48 @@ +package featurescomparison.workingwithformattingfeatures.workingwithcolors.java; + +import java.io.FileOutputStream; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; + +public class ApacheWorkingWithColors +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithformattingfeatures/workingwithcolors/data/"; + + Workbook wb = new HSSFWorkbook(); + Sheet sheet = wb.createSheet("new sheet"); + + // Create a row and put some cells in it. Rows are 0 based. + Row row = sheet.createRow((short) 1); + + // Aqua background + CellStyle style = wb.createCellStyle(); + style.setFillBackgroundColor(IndexedColors.AQUA.getIndex()); + style.setFillPattern(CellStyle.BIG_SPOTS); + Cell cell = row.createCell((short) 1); + cell.setCellValue("X"); + cell.setCellStyle(style); + + // Orange "foreground", foreground being the fill foreground not the font color. + style = wb.createCellStyle(); + style.setFillForegroundColor(IndexedColors.ORANGE.getIndex()); + style.setFillPattern(CellStyle.SOLID_FOREGROUND); + cell = row.createCell((short) 2); + cell.setCellValue("X"); + cell.setCellStyle(style); + + // Write the output to a file + FileOutputStream fileOut = new FileOutputStream(dataPath + "ApacheColors_Out.xls"); + wb.write(fileOut); + fileOut.close(); + + System.out.println("Apache Colors Created."); + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithformattingfeatures/workingwithcolors/java/AsposeWorkingWithColors.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithformattingfeatures/workingwithcolors/java/AsposeWorkingWithColors.java new file mode 100644 index 00000000..7999b4e4 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithformattingfeatures/workingwithcolors/java/AsposeWorkingWithColors.java @@ -0,0 +1,65 @@ +package featurescomparison.workingwithformattingfeatures.workingwithcolors.java; + +import com.aspose.cells.BackgroundType; +import com.aspose.cells.Cell; +import com.aspose.cells.Cells; +import com.aspose.cells.Color; +import com.aspose.cells.Font; +import com.aspose.cells.Style; +import com.aspose.cells.Workbook; +import com.aspose.cells.Worksheet; + +public class AsposeWorkingWithColors +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithformattingfeatures/workingwithcolors/data/"; + + //Instantiating a Workbook object + Workbook workbook = new Workbook(); + + //Accessing the added worksheet in the Excel file + Worksheet worksheet = workbook.getWorksheets().get(0); + Cells cells = worksheet.getCells(); + + // === Setting Background Pattern === + + //Accessing cell from the worksheet + Cell cell = cells.get("B2"); + Style style = cell.getStyle(); + + //Setting the foreground color to yellow + style.setBackgroundColor(Color.getYellow()); + + //Setting the background pattern to vertical stripe + style.setPattern(BackgroundType.VERTICAL_STRIPE); + + //Saving the modified style to the "A1" cell. + cell.setStyle(style); + + // === Setting Foreground === + + //Adding custom color to the palette at 55th index + Color color = Color.fromArgb(212,213,0); + workbook.changePalette(color,55); + + //Accessing the "A2" cell from the worksheet + cell = cells.get("B3"); + + //Adding some value to the cell + cell.setValue("Hello Aspose!"); + + //Setting the custom color to the font + style = cell.getStyle(); + Font font = style.getFont(); + font.setColor(color); + + cell.setStyle(style); + + //Saving the Excel file + workbook.save(dataPath + "AsposeColors_Out.xls"); + + System.out.println("Aspose Colors Created."); + + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithformattingfeatures/workingwithfonts/java/ApacheWorkingWithFonts.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithformattingfeatures/workingwithfonts/java/ApacheWorkingWithFonts.java new file mode 100644 index 00000000..216447be --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithformattingfeatures/workingwithfonts/java/ApacheWorkingWithFonts.java @@ -0,0 +1,48 @@ +package featurescomparison.workingwithformattingfeatures.workingwithfonts.java; + +import java.io.FileOutputStream; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; + +public class ApacheWorkingWithFonts +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithformattingfeatures/workingwithfonts/data/"; + + Workbook wb = new HSSFWorkbook(); + Sheet sheet = wb.createSheet("new sheet"); + + // Create a row and put some cells in it. Rows are 0 based. + Row row = sheet.createRow(1); + + // Create a new font and alter it. + Font font = wb.createFont(); + font.setFontHeightInPoints((short)24); + font.setFontName("Courier New"); + font.setItalic(true); + font.setStrikeout(true); + + // Fonts are set into a style so create a new one to use. + CellStyle style = wb.createCellStyle(); + style.setFont(font); + + // Create a cell and put a value in it. + Cell cell = row.createCell(1); + cell.setCellValue("This is a test of fonts"); + cell.setCellStyle(style); + + // Write the output to a file + FileOutputStream fileOut = new FileOutputStream(dataPath + "ApacheFonts.xls"); + wb.write(fileOut); + fileOut.close(); + + System.out.println("Apache Fonts Created."); + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithformattingfeatures/workingwithfonts/java/AsposeWorkingWithFonts.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithformattingfeatures/workingwithfonts/java/AsposeWorkingWithFonts.java new file mode 100644 index 00000000..3f46e9f6 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithformattingfeatures/workingwithfonts/java/AsposeWorkingWithFonts.java @@ -0,0 +1,47 @@ +package featurescomparison.workingwithformattingfeatures.workingwithfonts.java; + +import com.aspose.cells.Cell; +import com.aspose.cells.Cells; +import com.aspose.cells.Color; +import com.aspose.cells.Font; +import com.aspose.cells.FontUnderlineType; +import com.aspose.cells.Style; +import com.aspose.cells.Workbook; +import com.aspose.cells.Worksheet; + +public class AsposeWorkingWithFonts +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithformattingfeatures/workingwithfonts/data/"; + + //Instantiating a Workbook object + Workbook workbook = new Workbook(); + + //Accessing the worksheet in the Excel file + Worksheet worksheet = workbook.getWorksheets().get(0); + Cells cells = worksheet.getCells(); + + //Adding some value to cell + Cell cell = cells.get("A1"); + cell.setValue("This is Aspose test of fonts!"); + + //Setting the font name to "Times New Roman" + Style style = cell.getStyle(); + Font font = style.getFont(); + font.setName("Courier New"); + font.setSize(24); + font.setBold(true); + font.setUnderline(FontUnderlineType.SINGLE); + font.setColor(Color.getBlue()); + font.setStrikeout(true); + //font.setSubscript(true); + + cell.setStyle(style); + + //Saving the modified Excel file in default format + workbook.save(dataPath + "AsposeFonts.xls"); + + System.out.println("Aspose Fonts Created."); + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworkbook/adddataincells/java/ApacheInsertCellsData.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworkbook/adddataincells/java/ApacheInsertCellsData.java new file mode 100644 index 00000000..3fa940e0 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworkbook/adddataincells/java/ApacheInsertCellsData.java @@ -0,0 +1,43 @@ +package featurescomparison.workingwithworkbook.adddataincells.java; + +import java.io.FileOutputStream; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CreationHelper; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; + +public class ApacheInsertCellsData +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithworkbook/adddataincells/data/"; + + Workbook wb = new HSSFWorkbook(); + + CreationHelper createHelper = wb.getCreationHelper(); + Sheet sheet = wb.createSheet("new sheet"); + + // Create a row and put some cells in it. Rows are 0 based. + Row row = sheet.createRow((short)0); + // Create a cell and put a value in it. + Cell cell = row.createCell(0); + cell.setCellValue(1); + + // Or do it on one line. + row.createCell(1).setCellValue(1.2); + row.createCell(2).setCellValue( + createHelper.createRichTextString("This is a string")); + row.createCell(3).setCellValue(true); + + // Write the output to a file + FileOutputStream fileOut = new FileOutputStream(dataPath + "DataInCells_Apache_Out.xls"); + wb.write(fileOut); + fileOut.close(); + + // Print message + System.out.println("Data Added Successfully"); + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworkbook/adddataincells/java/AsposeInsertCellsData.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworkbook/adddataincells/java/AsposeInsertCellsData.java new file mode 100644 index 00000000..efb9c714 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworkbook/adddataincells/java/AsposeInsertCellsData.java @@ -0,0 +1,40 @@ +package featurescomparison.workingwithworkbook.adddataincells.java; + +import com.aspose.cells.Cell; +import com.aspose.cells.Cells; +import com.aspose.cells.Style; +import com.aspose.cells.Workbook; +import com.aspose.cells.Worksheet; + +public class AsposeInsertCellsData +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithworkbook/adddataincells/data/"; + + //Instantiating a Workbook object + Workbook workbook = new Workbook(); + + //Accessing the added worksheet in the Excel file + Worksheet worksheet = workbook.getWorksheets().get(0); + Cells cells = worksheet.getCells(); + + cells.get("A1").setValue("Hello World"); //Adding a string value to the cell + cells.get("A2").setValue(20.5); //Adding a double value to the cell + cells.get("A3").setValue(15); //Adding an integer value to the cell + cells.get("A4").setValue(true); //Adding a boolean value to the cell + + Cell cell = cells.get("A5"); //Adding a date/time value to the cell + cell.setValue(java.util.Calendar.getInstance()); + + //Setting the display format of the date + Style style = cell.getStyle(); + style.setNumber(15); + cell.setStyle(style); + + workbook.save(dataPath + "DataInCells_Aspose_Out.xls"); //Saving the Excel file + + // Print message + System.out.println("Data Added Successfully"); + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworkbook/createnewworkbook/java/ApachePOINewWorkbook.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworkbook/createnewworkbook/java/ApachePOINewWorkbook.java new file mode 100644 index 00000000..ff403f78 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworkbook/createnewworkbook/java/ApachePOINewWorkbook.java @@ -0,0 +1,23 @@ +package featurescomparison.workingwithworkbook.createnewworkbook.java; + +import java.io.FileOutputStream; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; + +public class ApachePOINewWorkbook +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithworkbook/createnewworkbook/data/"; + + Workbook wb = new HSSFWorkbook(); + + FileOutputStream fileOut; + fileOut = new FileOutputStream(dataPath + "newWorkBook_Apache_Out.xls"); + wb.write(fileOut); + fileOut.close(); + + System.out.println("File Created."); + } +} \ No newline at end of file diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworkbook/createnewworkbook/java/AsposeNewWorkbook.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworkbook/createnewworkbook/java/AsposeNewWorkbook.java new file mode 100644 index 00000000..4fec97bb --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworkbook/createnewworkbook/java/AsposeNewWorkbook.java @@ -0,0 +1,19 @@ +package featurescomparison.workingwithworkbook.createnewworkbook.java; + +import com.aspose.cells.FileFormatType; +import com.aspose.cells.Workbook; + +public class AsposeNewWorkbook +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithworkbook/createnewworkbook/data/"; + + Workbook workbook = new Workbook(); // Creating a Workbook object + + //Workbooks can be saved in many formats + workbook.save(dataPath + "newWorkBook_Aspose_Out.xlsx", FileFormatType.XLSX); + + System.out.println("Worksheets are saved successfully."); // Print Message + } +} \ No newline at end of file diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworkbook/setprintarea/java/ApachePrintArea.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworkbook/setprintarea/java/ApachePrintArea.java new file mode 100644 index 00000000..e54dfff2 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworkbook/setprintarea/java/ApachePrintArea.java @@ -0,0 +1,35 @@ +package featurescomparison.workingwithworkbook.setprintarea.java; + +import java.io.FileOutputStream; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; + +public class ApachePrintArea +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithworkbook/setprintarea/data/"; + + Workbook wb = new HSSFWorkbook(); + Sheet sheet = wb.createSheet("Sheet1"); + //sets the print area for the first sheet + wb.setPrintArea(0, "$A$1:$F$20"); + + //Alternatively: + wb.setPrintArea( + 0, //sheet index + 0, //start column + 1, //end column + 0, //start row + 0 //end row + ); + + FileOutputStream fileOut = new FileOutputStream(dataPath + "ApachePrintArea_Out.xls"); + wb.write(fileOut); + fileOut.close(); + + System.out.println("Print Area Set successfully."); // Print Message + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworkbook/setprintarea/java/AsposePrintArea.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworkbook/setprintarea/java/AsposePrintArea.java new file mode 100644 index 00000000..07aecf24 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworkbook/setprintarea/java/AsposePrintArea.java @@ -0,0 +1,33 @@ +package featurescomparison.workingwithworkbook.setprintarea.java; + +import com.aspose.cells.FileFormatType; +import com.aspose.cells.PageSetup; +import com.aspose.cells.Workbook; +import com.aspose.cells.Worksheet; +import com.aspose.cells.WorksheetCollection; + +public class AsposePrintArea +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithworkbook/setprintarea/data/"; + + // Instantiating a Workbook object + Workbook workbook = new Workbook(); + + // Accessing the first worksheet in the Workbook file + WorksheetCollection worksheets = workbook.getWorksheets(); + Worksheet sheet = worksheets.get(0); + + // Obtaining the reference of the PageSetup of the worksheet + PageSetup pageSetup = sheet.getPageSetup(); + + // Specifying the cells range (from A1 cell to F20 cell) of the print area + pageSetup.setPrintArea("A1:F20"); + + // Workbooks can be saved in many formats + workbook.save(dataPath + "AsposePrintArea_Out.xlsx", FileFormatType.XLSX); + + System.out.println("Print Area Set successfully."); // Print Message + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/copysheetwithinworkbook/java/ApacheCopySheetWithinWorkbook.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/copysheetwithinworkbook/java/ApacheCopySheetWithinWorkbook.java new file mode 100644 index 00000000..5c4cdfd7 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/copysheetwithinworkbook/java/ApacheCopySheetWithinWorkbook.java @@ -0,0 +1,21 @@ +package featurescomparison.workingwithworksheets.copysheetwithinworkbook.java; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; + +public class ApacheCopySheetWithinWorkbook +{ + public static void main(String[] args) throws Exception + { + Workbook wb = new HSSFWorkbook(); + wb.createSheet("new sheet"); + wb.createSheet("second sheet"); + Sheet cloneSheet = wb.cloneSheet(0); + + // now you have to manually copy all the data into new sheet from the cloneSheet + + //Print Message + System.out.println("Cloned successfull."); + } +} \ No newline at end of file diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/copysheetwithinworkbook/java/AsposeCopySheetWithinWorkbook.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/copysheetwithinworkbook/java/AsposeCopySheetWithinWorkbook.java new file mode 100644 index 00000000..1a238442 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/copysheetwithinworkbook/java/AsposeCopySheetWithinWorkbook.java @@ -0,0 +1,27 @@ +package featurescomparison.workingwithworksheets.copysheetwithinworkbook.java; + +import com.aspose.cells.Workbook; +import com.aspose.cells.WorksheetCollection; + +public class AsposeCopySheetWithinWorkbook +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithworksheets/copysheetwithinworkbook/data/"; + + //Create a new Workbook by excel file path + Workbook wb = new Workbook(); + + //Create a Worksheets object with reference to the sheets of the Workbook. + WorksheetCollection sheets = wb.getWorksheets(); + + //Copy data to a new sheet from an existing + //sheet within the Workbook. + sheets.addCopy("Sheet1"); + + //Save the excel file. + wb.save(dataPath + "AsposeCopyWorkbook_Out.xls"); + + System.out.println("Sheet copied successfully."); // Print Message + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/createnewworksheet/java/ApachePOINewWorksheet.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/createnewworksheet/java/ApachePOINewWorksheet.java new file mode 100644 index 00000000..2d884678 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/createnewworksheet/java/ApachePOINewWorksheet.java @@ -0,0 +1,44 @@ +package featurescomparison.workingwithworksheets.createnewworksheet.java; + +import java.io.FileOutputStream; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.util.WorkbookUtil; + +public class ApachePOINewWorksheet +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithworksheets/createnewworksheet/data/"; + + Workbook wb = new HSSFWorkbook(); // or new XSSFWorkbook(); + Sheet sheet1 = wb.createSheet("new sheet"); + Sheet sheet2 = wb.createSheet("second sheet"); + + // Note that sheet name is Excel must not exceed 31 characters + // and must not contain any of the any of the following characters: + // 0x0000 + // 0x0003 + // colon (:) + // backslash (\) + // asterisk (*) + // question mark (?) + // forward slash (/) + // opening square bracket ([) + // closing square bracket (]) + + // You can use org.apache.poi.ss.util.WorkbookUtil#createSafeSheetName(String nameProposal)} + // for a safe way to create valid names, this utility replaces invalid characters with a space (' ') + String safeName = WorkbookUtil.createSafeSheetName("[O'Brien's sales*?]"); + Sheet sheet3 = wb.createSheet(safeName); + + FileOutputStream fileOut = new FileOutputStream(dataPath + "newWorksheet_Apache_Out.xls"); + wb.write(fileOut); + fileOut.close(); + + //Print Message + System.out.println("Sheet added successfully."); + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/createnewworksheet/java/AsposeNewWorksheet.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/createnewworksheet/java/AsposeNewWorksheet.java new file mode 100644 index 00000000..47d9db48 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/createnewworksheet/java/AsposeNewWorksheet.java @@ -0,0 +1,26 @@ +package featurescomparison.workingwithworksheets.createnewworksheet.java; + +import com.aspose.cells.Workbook; +import com.aspose.cells.Worksheet; +import com.aspose.cells.WorksheetCollection; + +public class AsposeNewWorksheet +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithworksheets/createnewworksheet/data/"; + + //Instantiating a Workbook object + Workbook workbook = new Workbook(); + + //Adding a new worksheet to the Workbook object + WorksheetCollection worksheets = workbook.getWorksheets(); + Worksheet worksheet = worksheets.add("My Worksheet"); + + //Saving the Excel file + workbook.save(dataPath + "newWorksheet_Aspose_Out.xls"); + + //Print Message + System.out.println("Sheet added successfully."); + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/headerandfooter/data/footer.png b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/headerandfooter/data/footer.png new file mode 100644 index 00000000..60f661a4 Binary files /dev/null and b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/headerandfooter/data/footer.png differ diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/headerandfooter/java/ApacheHeaderFooter.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/headerandfooter/java/ApacheHeaderFooter.java new file mode 100644 index 00000000..be2ac273 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/headerandfooter/java/ApacheHeaderFooter.java @@ -0,0 +1,32 @@ +package featurescomparison.workingwithworksheets.headerandfooter.java; + +import java.io.FileOutputStream; + +import org.apache.poi.hssf.usermodel.HSSFHeader; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Header; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; + +public class ApacheHeaderFooter +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithworksheets/headerandfooter/data/"; + + Workbook wb = new HSSFWorkbook(); + Sheet sheet = wb.createSheet("new sheet"); + + Header header = sheet.getHeader(); + header.setCenter("Center Header"); + header.setLeft("Left Header"); + header.setRight(HSSFHeader.font("Stencil-Normal", "Italic") + + HSSFHeader.fontSize((short) 16) + "Right w/ Stencil-Normal Italic font and size 16"); + + FileOutputStream fileOut = new FileOutputStream(dataPath + "ApacheHeaderFooter_Out.xls"); + wb.write(fileOut); + fileOut.close(); + + System.out.println("Aspose Header Footer Created."); + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/headerandfooter/java/AsposeHeaderFooter.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/headerandfooter/java/AsposeHeaderFooter.java new file mode 100644 index 00000000..2e17aa2d --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/headerandfooter/java/AsposeHeaderFooter.java @@ -0,0 +1,50 @@ +package featurescomparison.workingwithworksheets.headerandfooter.java; + +import java.io.FileInputStream; + +import com.aspose.cells.PageSetup; +import com.aspose.cells.Workbook; + +public class AsposeHeaderFooter +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithworksheets/headerandfooter/data/"; + + //Instantiating a Workbook object + Workbook workbook = new Workbook(); + + //Obtaining the reference of the PageSetup of the worksheet + PageSetup pageSetup = workbook.getWorksheets().get(0).getPageSetup(); + + //Setting worksheet name at the left header + pageSetup.setHeader(0, "&A"); + + //Setting current date and current time at the central header + //and changing the font of the header + pageSetup.setHeader(1, "&\"Times New Roman,Bold\"&D-&T"); + + //Setting current file name at the right header and changing the font of the header + pageSetup.setHeader(2, "&\"Times New Roman,Bold\"&12&F"); + + //Setting a string at the left footer and changing the font of the footer + pageSetup.setFooter(0, "Hello World! &\"Courier New\"&14 123"); + + //Setting picture at the central footer + pageSetup.setFooter(1, "&G"); + + FileInputStream fis = new FileInputStream(dataPath + "footer.png"); + byte[] picData = new byte[fis.available()]; + fis.read(picData); + pageSetup.setFooterPicture(1, picData); + fis.close(); + + //Setting the current page number and page count at the right footer + pageSetup.setFooter(2, "&Pof&N"); + + //Saving the workbook + workbook.save(dataPath + "AsposeHeaderFooter_Out.xls"); + + System.out.println("Aspose Header Footer Created."); + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/reordersheetswithinworkbook/java/ApacheMoveSheetWithinWorkbook.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/reordersheetswithinworkbook/java/ApacheMoveSheetWithinWorkbook.java new file mode 100644 index 00000000..ffd0dce9 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/reordersheetswithinworkbook/java/ApacheMoveSheetWithinWorkbook.java @@ -0,0 +1,30 @@ +package featurescomparison.workingwithworksheets.reordersheetswithinworkbook.java; + +import java.io.FileOutputStream; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Workbook; + +public class ApacheMoveSheetWithinWorkbook +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithworksheets/reordersheetswithinworkbook/data/"; + + Workbook wb = new HSSFWorkbook(); + wb.createSheet("new sheet"); + wb.createSheet("second sheet"); + wb.createSheet("third sheet"); + + wb.setSheetOrder("second sheet", 0); + wb.setSheetOrder("new sheet", 1); + wb.setSheetOrder("third sheet", 2); + + FileOutputStream fileOut = new FileOutputStream(dataPath + "Apache_Reordered_Out.xls"); + wb.write(fileOut); + fileOut.close(); + + //Print Message + System.out.println("Reordered successfull."); + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/reordersheetswithinworkbook/java/AsposeMoveSheetWithinWorkbook.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/reordersheetswithinworkbook/java/AsposeMoveSheetWithinWorkbook.java new file mode 100644 index 00000000..b1cb8284 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/reordersheetswithinworkbook/java/AsposeMoveSheetWithinWorkbook.java @@ -0,0 +1,31 @@ +package featurescomparison.workingwithworksheets.reordersheetswithinworkbook.java; + +import com.aspose.cells.Workbook; +import com.aspose.cells.Worksheet; +import com.aspose.cells.WorksheetCollection; + +public class AsposeMoveSheetWithinWorkbook +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithworksheets/reordersheetswithinworkbook/data/"; + + //Create a new Workbook. + Workbook workbook = new Workbook(); + + WorksheetCollection worksheets = workbook.getWorksheets(); + Worksheet worksheet1 = worksheets.get(0); + Worksheet worksheet2 = worksheets.add("Sheet2"); + Worksheet worksheet3 = worksheets.add("Sheet3"); + + //Move Sheets with in Workbook. + worksheet2.moveTo(0); + worksheet1.moveTo(1); + worksheet3.moveTo(2); + + //Save the excel file. + workbook.save(dataPath + "AsposeMoveSheet_Out.xls"); + + System.out.println("Sheet moved successfully."); // Print Message + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/zoomfactor/java/ApacheZoom.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/zoomfactor/java/ApacheZoom.java new file mode 100644 index 00000000..779dfea9 --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/zoomfactor/java/ApacheZoom.java @@ -0,0 +1,26 @@ +package featurescomparison.workingwithworksheets.zoomfactor.java; + +import java.io.FileOutputStream; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; + +public class ApacheZoom +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithworksheets/zoomfactor/data/"; + + Workbook wb = new HSSFWorkbook(); + Sheet sheet1 = wb.createSheet("new sheet"); + sheet1.setZoom(3,4); // 75 percent magnification + + // Write the output to a file + FileOutputStream fileOut = new FileOutputStream(dataPath + "ApacheZoom_Out.xls"); + wb.write(fileOut); + fileOut.close(); + + System.out.println("Process Completed Successfully."); + } +} diff --git a/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/zoomfactor/java/AsposeZoom.java b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/zoomfactor/java/AsposeZoom.java new file mode 100644 index 00000000..1a814c9b --- /dev/null +++ b/Plugins/Aspose_Cells_for_Apache_POI/src/featurescomparison/workingwithworksheets/zoomfactor/java/AsposeZoom.java @@ -0,0 +1,28 @@ +package featurescomparison.workingwithworksheets.zoomfactor.java; + +import com.aspose.cells.Workbook; +import com.aspose.cells.Worksheet; +import com.aspose.cells.WorksheetCollection; + +public class AsposeZoom +{ + public static void main(String[] args) throws Exception + { + String dataPath = "src/featurescomparison/workingwithworksheets/zoomfactor/data/"; + + //Instantiating a Excel object by excel file path + Workbook workbook = new Workbook(); + + //Accessing the first worksheet in the Excel file + WorksheetCollection worksheets = workbook.getWorksheets(); + Worksheet worksheet = worksheets.get(0); + + //Setting the zoom factor of the worksheet to 75 + worksheet.setZoom(75); + + //Saving the modified Excel file in default format + workbook.save(dataPath + "AsposeZoom_Out.xls"); + + System.out.println("Aspose Zoom Created."); + } +}