Package com.aspose.cells

Examples of com.aspose.cells.Workbook


public class AsposePrintWorkbook
{
  public static void main(String[] args) throws Exception
  {
    //Instantiate a new workbook
    Workbook book = new Workbook("data/AsposeDataInput.xls");

    //Create an object for ImageOptions
    ImageOrPrintOptions  imgOptions = new ImageOrPrintOptions ();

    //Get the first worksheet
    Worksheet sheet = book.getWorksheets().get(0);
   
    //Create a SheetRender object with respect to your desired sheet
    SheetRender sr = new SheetRender(sheet, imgOptions);

    //Print the worksheet 
View Full Code Here


public class AsposePrintTitles
{
  public static void main(String[] args) throws Exception
  {
    //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();    
   
    //Defining column numbers A & B as title columns
    pageSetup.setPrintTitleColumns("$A:$B");
   
    //Defining row numbers 1 & 2 as title rows
    pageSetup.setPrintTitleRows("$1:$2");
   
    // Workbooks can be saved in many formats
    workbook.save("data/AsposePrintTitles.xlsx", FileFormatType.XLSX);

    System.out.println("Print Titles Set successfully."); // Print Message
  }
View Full Code Here

public class AsposeFindCellsWithString
{
  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);
   
    //Finding the cell containing the specified formula
    Cells cells = worksheet.getCells();
   
    //Instantiate FindOptions
View Full Code Here

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

public class AsposeCharts
{
  public static void main(String[] args) throws Exception
  {
      // 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);

        // Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
        SeriesCollection serieses = chart.getNSeries();
        serieses.add("A1:B3", true);

        // Saving the Excel file
        workbook.save("data/AsposeChart.xls");
       
        // Print message
        System.out.println("Workbook with chart is successfully created.");
  }
View Full Code Here

public class AsposePivotChart
{
  public static void main(String[] args) throws Exception
  {
    // 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);
   
    // Saving the Excel file
    workbook.save("data/Aspose_PivotChart.xls");
   
    // Print Message
    System.out.println("Pivot Chart created successfully.");
  }
View Full Code Here

public class TracingPrecedentsAndDependents
{
  public static void main(String[] args) throws Exception
  {
    //Instantiating a Workbook object
    Workbook workbook = new Workbook("data/workbook.xls");
   
    Cells cells = workbook.getWorksheets().get(0).getCells();
    Cell cell = cells.get("A12");
   
    //Tracing precedents of the cell A12.
    //The return array contains ranges and cells.
    ReferredAreaCollection ret = cell.getPrecedents();
View Full Code Here

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

  {
    //Creating a file stream containing the Excel file to be opened
    FileInputStream fstream = new FileInputStream("data/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++)
View Full Code Here

public class AsposeDataSort
{
  public static void main(String[] args) throws Exception
  {
    //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
    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("data/AsposeSortedData.xls");
  }
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.