Search
Importing

Importing from CSV

To import a worksheet from an CSV (comma-separated values) file, create an instance of the CsvImporter class, set the appropriate properties and call the importData method. The Quote and getSeparator properties can be used to specify the quote and separator characters respectively in the imported file. The CsvImportForm can be used to facilitate the import from CSV.

The following example illustrates how to import a worksheet from an CSV file:

Java  Copy Code

CsvImporter csvImporter = new CsvImporter();
try
{
    csvImporter.importData("d:\\mysheet.csv", worksheet);
}
catch (IOException ex)
{
}

Importing from ODS Files

To import a workbook from an ODS (OpenDocument) file, create an instance of the CalcImporter class and call the importCalc method. The following example illustrates how to do this:

Java  Copy Code

CalcImporter calcImporter = new CalcImporter();
calcImporter.importCalc("d:\\mysheet.ods", workbook);

Importing from XLSX Files

To import a workbook from an XLSX (Office Open XML) file, create an instance of the ExcelImporter class and call the importXlsx method. The following example illustrates how to do this:

Java  Copy Code

ExcelImporter excelImporter = new ExcelImporter();
excelImporter.importXlsx("d:\\mysheet.xlsx", workbook);