WikiTaskTutorial/Excel

From BITPlan Wiki
Revision as of 09:42, 27 April 2020 by Wf (talk | contribs) (created by WikiTask 2020-04-27T07:42:14Z)
Jump to navigation Jump to search


This is an Example for accessing an Excel xlsx document from a WikiTask. The example file is http://cdcontent.books24x7.com/id_16959/real%20estate%20table.xlsx.

template

This template includes Office#Excel

@include(wiki.Office.Excel)
Excel file: @(wikiTask.getInput()) 
@if(excel.error) {  
can not be opened due to error @(excel.error.getMessage())
} else { has the following sheets:
@for (int i=0;i<excel.workbook.getNumberOfSheets();i++) { @{XSSFSheet sheet = excel.workbook.getSheetAt(i);List<List<String>> sheetContent=excel.getSheetContent(sheet);String delim="!"} 
=== @(sheet.getSheetName()) ===
@("{")|class="wikitable sortable"
@for (List<String> row:sheetContent) { @for (col:row) {
@(delim)@col
}
|-
@{ delim="|" }
}
@("|}")
}
}
@{ try { excel.workbook.close(); }  catch (Throwable th) { }}
{{wikitask|cmd=runtemplate|input=http://cdcontent.books24x7.com/id_16959/real%20estate%20table.xlsx|engine=Rythm|template={{FULLPAGENAMEE}}#template|targetpage={{FULLPAGENAMEE}}#result}}

runtemplate -> WikiTaskTutorial/Excel#result

result

Excel file: http://cdcontent.books24x7.com/id_16959/real%20estate%20table.xlsx can not be opened due to error No valid entries or contents found, this is not a valid OOXML (Office Open XML) file