Package com.aspose.cells

Examples of com.aspose.cells.Worksheet


  {
    //Create a new Workbook.
    Workbook workbook = new Workbook();

    //Get the first worksheet.
    Worksheet sheet = workbook.getWorksheets().get(0);

    //Set the name of worksheet
    sheet.setName("Data");

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

    //Put some values into a cells of the Data sheet.
    cells.get("A1").setValue("Region");
    cells.get("A2").setValue("France");
    cells.get("A3").setValue("Germany");
    cells.get("A4").setValue("England");
    cells.get("A5").setValue("Sweden");
    cells.get("A6").setValue("Italy");
    cells.get("A7").setValue("Spain");
    cells.get("A8").setValue("Portugal");
    cells.get("B1").setValue("Sale");
    cells.get("B2").setValue(70000);
    cells.get("B3").setValue(55000);
    cells.get("B4").setValue(30000);
    cells.get("B5").setValue(40000);
    cells.get("B6").setValue(35000);
    cells.get("B7").setValue(32000);
    cells.get("B8").setValue(10000);

    //Create chart
    int chartIndex = sheet.getCharts().add(ChartType.COLUMN, 12, 1, 33, 12);
    Chart chart = sheet.getCharts().get(chartIndex);

    //Set properties of chart title
    chart.getTitle().setText("Sales By Region");
    chart.getTitle().getTextFont().setBold(true);
    chart.getTitle().getTextFont().setSize(12);
View Full Code Here


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

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

        // Adding some sample value to cells
        Cells cells = sheet.getCells();
        Cell cell = cells.get("A1");
        cell.setValue(50);
        cell = cells.get("A2");
        cell. setValue (100);
        cell = cells.get("A3");
        cell.setValue(150);
        cell = cells.get("B1");
        cell.setValue(4);
        cell = cells.get("B2");
        cell.setValue(20);
        cell = cells.get("B3");
        cell.setValue(50);

        ChartCollection charts = sheet.getCharts();

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

    // Instantiating an Workbook object
    Workbook workbook = new Workbook("data/AsposePivotTable.xls");

    // Adding a new sheet
    int sheetIndex = workbook.getWorksheets().add(SheetType.CHART);
    Worksheet sheet3 = workbook.getWorksheets().get(sheetIndex);

    // Naming the sheet
    sheet3.setName("PivotChart");
   
    // Adding a column chart
    int chartIndex = sheet3.getCharts().add(ChartType.COLUMN, 0, 5, 28, 16);
    Chart chart = sheet3.getCharts().get(chartIndex);
   
    // Setting the pivot chart data source
    chart.setPivotSource("PivotTable!PivotTable1");
    chart.setHidePivotFieldButtons(false);
   
View Full Code Here

    //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>();
   
View Full Code Here

   
    //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]));
    }
View Full Code Here

  {
    //Instantiating a Workbook object
    Workbook workbook = new Workbook("data/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
View Full Code Here

    //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);
View Full Code Here

  {
    //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");
   
View Full Code Here

  {
        //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
View Full Code Here

  {
    //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
View Full Code Here

TOP

Related Classes of com.aspose.cells.Worksheet

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.