// Create a new workbook Workbook workbook = new Workbook(); // Open an excel file. InputStream fileStream = this.getResourceStream("xlsx\\AgingReport.xlsx"); // Get the possible import names in the file. // The names[0] and names[1] are sheet names: "Aging Report", "Invoices". // The names[2] and names[3] are table names: "'Aging Report'!tblAging", "Invoices!tblInvoices". String[] names = Workbook.getNames(fileStream); // The InputStream of the Java platform cannot be read repeatedly, so you need to create another one. InputStream fileStream2 = this.getResourceStream("xlsx\\AgingReport.xlsx"); // Import the data of a table "'Aging Report'!tblAging" from the fileStream. Object[][] data = Workbook.importData(fileStream2, names[2]); // Assign the data to current workbook. workbook.getWorksheets().get(0).getRange(0, 0, data.length, data[0].length).setValue(data); // Save to an excel file workbook.save("ImportDataForTable.xlsx");
// Create a new workbook var workbook = Workbook() // Open an excel file. val fileStream = getResourceStream("xlsx\\AgingReport.xlsx") // Get the possible import names in the file. // The names[0] and names[1] are sheet names: "Aging Report", "Invoices". // The names[2] and names[3] are table names: "'Aging Report'!tblAging", "Invoices!tblInvoices". val names: Array = Workbook.getNames(fileStream) // The InputStream of the Java platform cannot be read repeatedly, so you need to create another one. val fileStream2 = getResourceStream("xlsx\\AgingReport.xlsx") // Import the data of a table "'Aging Report'!tblAging" from the fileStream. val data: Array> = Workbook.importData(fileStream2, names[2]) // Assign the data to current workbook. workbook.worksheets[0].getRange(0, 0, data.size, data[0].size).setValue(data) // Save to an excel file workbook.save("ImportDataForTable.xlsx")