Package com.aspose.cells

Examples of com.aspose.cells.Workbook


public class AsposeConverter
{
  public static void main(String[] args) throws Exception
  {
    Workbook workbook = new Workbook("data/workbook.xls");
   
    //Save the document in PDF format
    workbook.save("data/AsposeConvert.pdf", SaveFormat.PDF);

        // Print message
        System.out.println("Excel to PDF conversion performed successfully.");
  }
View Full Code Here


public class AsposeFormulaCalculationEngine
{
  public static void main(String[] args) throws Exception
  {
    //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("data/AsposeFormulaEngine.xls");
  }
View Full Code Here

public class AsposeCreateSubTotals
{
  public static void main(String[] args) throws Exception
  {
    //Instantiate a new workbook
    Workbook workbook = new Workbook("data/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("data/AsposeTotal.xls");
   
    // Print message
    System.out.println("Process completed successfully");
  }
View Full Code Here

public class AsposeDetectMergeCells
{
  public static void main(String[] args) throws Exception
  {
    //Instantiate a new Workbook
    Workbook workbook = new Workbook("data/MergeInput.xls");
   
    //Get a worksheet in the workbook
    Worksheet worksheet = workbook.getWorksheets().get(0);
   
    //Clear its contents
    worksheet.getCells().clearContents(0,0,worksheet.getCells().getMaxDataRow(),worksheet.getCells().getMaxDataColumn());

    //Create an arraylist object
    //Get the merged cells list to put it into the arraylist object      
    ArrayList<CellArea> al = worksheet.getCells().getMergedCells();
   
    //Define cellarea
    CellArea ca;
   
    //Define some variables
    int frow, fcol, erow, ecol;
   
    // Print Message
    System.out.println("Merged Areas: \n"+ al.toString());
   
    //Loop through the arraylist and get each cellarea to unmerge it
    for(int i = al.size()-1 ; i > -1; i--)
    {
      ca = new CellArea();
      ca = (CellArea)al.get(i);
      frow = ca.StartRow;
      fcol = ca.StartColumn;
      erow = ca.EndRow;
      ecol = ca.EndColumn;
      System.out.println((i+1) + ". [" + fcol +"," + frow +"] " + "[" + ecol +"," + erow +"]");
      worksheet.getCells().unMerge(frow, fcol, erow, ecol);
    }

    //Save the excel file
    workbook.save("data/AsposeMergeOutput.xls");
   
    // Print Message
    System.out.println("Detect Merge Cells successful.");
  }
View Full Code Here

public class AsposeAutoFit
{
  public static void main(String[] args) throws Exception
  {
        //Instantiating a Workbook object
        Workbook workbook = new Workbook("data/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("data/AutoFit_Aspose.xls");
       
        //Print message
        System.out.println("Row and Column auto fit successfully.");

  }
View Full Code Here

public class AsposeInsertCellsData
{
  public static void main(String[] args) throws Exception
  {
    //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("data/DataInCells_Aspose.xls"); //Saving the Excel file

// Print message
System.out.println("Data Added Successfully");
  }
View Full Code Here

public class AsposeCopySheetWithinWorkbook
{
  public static void main(String[] args) throws Exception
  {
    //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("data/AsposeCopyWorkbook.xls");
   
    System.out.println("Sheet copied successfully."); // Print Message
  }
View Full Code Here

public class AsposeMoveSheetWithinWorkbook
{
  public static void main(String[] args) throws Exception
  {
    //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("data/AsposeMoveSheet.xls");
   
    System.out.println("Sheet moved successfully."); // Print Message
  }
View Full Code Here

public class AsposeZoom
{
  public static void main(String[] args) throws Exception
  {
    //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("data/AsposeZoom.xls");
   
    System.out.println("Aspose Zoom Created.");
  }
View Full Code Here

public class AsposeMergeCells
{
  public static void main(String[] args) throws Exception
  {
    //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("data/merge_Aspose.xls");
   
    // Print message
    System.out.println("Process completed successfully");
  }
View Full Code Here

TOP

Related Classes of com.aspose.cells.Workbook

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.