public static void main(String[] args) throws Exception {
   // The path to the documents directory.
   String dataDir = Utils.getSharedDataDir(UsingHTMLProperty.class) + "SmartMarkers/";
   Workbook workbook = new Workbook();
   WorkbookDesigner designer = new WorkbookDesigner();
   designer.setWorkbook(workbook);
   workbook.getWorksheets().get(0).getCells().get("A1").putValue("&=$VariableArray(HTML)");
   designer.setDataSource(
       "VariableArray", new String[] {"Hello <b>World</b>", "Arabic", "Hindi", "Urdu", "French"});
   designer.process();
   workbook.save(dataDir + "UHProperty-out.xls");
 }
  public static void main(String[] args) throws Exception {
    String dataDir = Utils.getSharedDataDir(InsertingARow.class) + "rows_cloumns/";
    // Instantiating a Workbook object
    Workbook workbook = new Workbook(dataDir + "book1.xls");

    // Accessing the first worksheet in the Excel file
    Worksheet worksheet = workbook.getWorksheets().get(0);

    // Inserting a row into the worksheet at 3rd position
    worksheet.getCells().insertRows(2, 1);

    // Saving the modified Excel file in default (that is Excel 2000) format
    workbook.save(dataDir + "InsertingARow_out.xls");
  }
  public static void main(String[] args) throws Exception {

    // The path to the documents directory.
    String dataDir = Utils.getSharedDataDir(CopyingSingleRow.class) + "articles/";
    // Create an instance of Workbook class by loading the existing spreadsheet
    Workbook workbook = new Workbook(dataDir + "aspose-sample.xlsx");

    // Get the cells collection of first worksheet
    Cells cells = workbook.getWorksheets().get(0).getCells();

    // Copy the first row to next 10 rows
    for (int i = 1; i <= 10; i++) {
      cells.copyRow(cells, 0, i);
    }
    // Save the result on disc
    workbook.save(dataDir + "CSingleRow_out.xlsx");
  }
  public static void main(String[] args) throws Exception {
    // Path to source file
    String dataDir =
        Utils.getSharedDataDir(AccessingMaximumDisplayRangeofWorksheet.class) + "data/";

    // Instantiate a workbook from source file
    Workbook workbook = new Workbook(dataDir + "Book1.xlsx");

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

    // Access the Maximum Display Range
    Range range = worksheet.getCells().getMaxDisplayRange();

    // Print the Maximum Display Range RefersTo property
    System.out.println("Maximum Display Range: " + range.getRefersTo());
  }
  public static void main(String[] args) throws Exception {
    // The path to the documents directory.
    String dataDir =
        Utils.getSharedDataDir(ConvertingsingleWorksheetToXPS.class) + "loading_saving/";

    // Open an Excel file
    Workbook workbook = new Workbook(dataDir + "Book1.xlsx");

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

    // Apply different Image and Print options
    ImageOrPrintOptions options = new ImageOrPrintOptions();
    // Set the format
    options.setSaveFormat(SaveFormat.XPS);

    // Render the sheet with respect to specified printing options
    SheetRender render = new SheetRender(sheet, options);
    render.toImage(0, dataDir + "CSingleWorksheetToXPS_out.xps");
  }
  public static void main(String[] args) throws Exception {

    // The path to the documents directory.
    String dataDir = Utils.getSharedDataDir(SettheCommentofTableorListObject.class) + "articles/";

    // Open the template file.
    Workbook workbook = new Workbook(dataDir + "source.xlsx");

    // Access first worksheet.
    Worksheet worksheet = workbook.getWorksheets().get(0);

    // Access first list object or table.
    ListObject lstObj = worksheet.getListObjects().get(0);

    // Set the comment of the list object
    lstObj.setComment("This is Aspose.Cells comment.");

    // Save the workbook in xlsx format
    workbook.save(dataDir + "STheCofTOrListObject_out.xlsx", SaveFormat.XLSX);
  }
  public static void main(String[] args) throws Exception {

    String dataDir = Utils.getSharedDataDir(ReadingAndWritingQueryTable.class) + "articles/";
    // Create workbook from source excel file
    Workbook workbook = new Workbook(dataDir + "Sample.xlsx");

    // Access first worksheet
    Worksheet worksheet = workbook.getWorksheets().get(0);

    // Access first Query Table
    QueryTable qt = worksheet.getQueryTables().get(0);

    // Print Query Table Data
    System.out.println("Adjust Column Width: " + qt.getAdjustColumnWidth());
    System.out.println("Preserve Formatting: " + qt.getPreserveFormatting());

    // Now set Preserve Formatting to true
    qt.setPreserveFormatting(true);

    // Save the workbook
    workbook.save(dataDir + "RAWQueryTable_out.xlsx");
  }
  public static void main(String[] args) throws Exception {

    // The path to the documents directory.
    String dataDir = Utils.getSharedDataDir(SetBackgroundPictureforWorksheet.class) + "articles/";
    // Instantiate a new Workbook.
    Workbook workbook = new Workbook();
    // Get the first worksheet.
    Worksheet sheet = workbook.getWorksheets().get(0);

    // Get the image file.
    File file = new File(dataDir + "school.jpg");
    // Get the picture into the streams.
    byte[] imageData = new byte[(int) file.length()];
    FileInputStream fis = new FileInputStream(file);
    fis.read(imageData);

    // Set the background image for the sheet.
    sheet.setBackgroundImage(imageData);

    // Save the excel file
    workbook.save(dataDir + "SBPforWorksheet.xls");
  }
  public static void main(String[] args) throws Exception {

    // The path to the documents directory.
    String dataDir = Utils.getSharedDataDir(ActivatingSheetsandActivatingCell.class) + "articles/";
    // Instantiate a new Workbook
    Workbook workbook = new Workbook();
    // Get the first worksheet in the workbook
    Worksheet worksheet = workbook.getWorksheets().get(0);
    // Get the cells in the worksheet
    Cells cells = worksheet.getCells();
    // Input data into B2 cell
    cells.get(1, 1).putValue("Hello World!");
    // Set the first sheet as an active sheet
    workbook.getWorksheets().setActiveSheetIndex(0);
    // Set B2 cell as an active cell in the worksheet
    worksheet.setActiveCell("B2");
    // Set the B column as the first visible column in the worksheet
    worksheet.setFirstVisibleColumn(1);
    // Set the 2nd row as the first visible row in the worksheet
    worksheet.setFirstVisibleRow(1);
    // Save the excel file
    workbook.save(dataDir + "ASAActivatingCell_out.xls");
  }
  public static void main(String[] args) throws Exception {

    // The path to the documents directory.
    String dataDir = Utils.getSharedDataDir(InsertLinkedPicturefromWebAddress.class) + "articles/";
    // Instantiate a new Workbook.
    Workbook workbook = new Workbook();
    // Insert a linked picture (from Web Address) to B2 Cell.
    Picture pic =
        (Picture)
            workbook
                .getWorksheets()
                .get(0)
                .getShapes()
                .addLinkedPicture(1, 1, 100, 100, "http://www.aspose.com/Images/aspose-logo.jpg");
    // Set the source of the inserted image.
    pic.setSourceFullName("http://www.aspose.com/images/aspose-logo.gif");

    // Set the height and width of the inserted image.
    pic.setHeightInch(1.04);
    pic.setWidthInch(2.6);

    // Save the Excel file.
    workbook.save(dataDir + "ILPfromWebAddress_out.xlsx");
  }
  public static void main(String[] args) throws Exception {

    // The path to the documents directory.
    String dataDir = Utils.getSharedDataDir(WrapTextinCell.class) + "articles/";

    // Create Workbook Object
    Workbook wb = new Workbook();

    // Open first Worksheet in the workbook
    Worksheet ws = wb.getWorksheets().get(0);

    // Get Worksheet Cells Collection
    Cells cell = ws.getCells();

    // Increase the width of First Column Width
    cell.setColumnWidth(0, 35);

    // Increase the height of first row
    cell.setRowHeight(0, 65);

    // Add Text to the First Cell
    cell.get(0, 0)
        .setValue("I am using the latest version of Aspose.Cells to test this functionality");

    // Get Cell's Style
    Style style = cell.get(0, 0).getStyle();

    // Set Text Wrap property to true
    style.setTextWrapped(true);

    // Set Cell's Style
    cell.get(0, 0).setStyle(style);

    // Save Excel File
    wb.save(dataDir + "WrapTextinCell_out.xls");
  }