WikiTaskTutorial/Excel97


Wolfgang Fahl


This is an Example for accessing an Excel97 xls document from a WikiTask. The example file is http://file-examples.com/wp-content/uploads/2017/02/file_example_XLS_50.xls.

template

This template includes Office#Excel97

@include(wiki.Office.Excel97)
The 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++) { @{HSSFSheet 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)<nowiki>@col</nowiki>
}
|-
@{ delim="|" }
}
@("|}")
}
}
@{ try { excel.workbook.close(); }  catch (Throwable th) { }}
{{wikitask|cmd=runtemplate|input=http://file-examples.com/wp-content/uploads/2017/02/file_example_XLS_50.xls|engine=Rythm|template={{FULLPAGENAMEE}}#template|targetpage={{FULLPAGENAMEE}}#result}}

runtemplate -> WikiTaskTutorial/Excel97#result

template[edit]

This template includes Office#Excel97

@include(wiki.Office.Excel97)
The 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++) { @{HSSFSheet 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)<nowiki>@col</nowiki>
}
|-
@{ delim="|" }
}
@("|}")
}
}
@{ try { excel.workbook.close(); }  catch (Throwable th) { }}
{{wikitask|cmd=runtemplate|input=http://file-examples.com/wp-content/uploads/2017/02/file_example_XLS_50.xls|engine=Rythm|template={{FULLPAGENAMEE}}#template|targetpage={{FULLPAGENAMEE}}#result}}

runtemplate -> WikiTaskTutorial/Excel97#result

result[edit]

The Excel file: http://file-examples.com/wp-content/uploads/2017/02/file_example_XLS_50.xls can not be opened due to error Invalid header signature; read 0x505954434F44213C, expected 0xE11AB1A1E011CFD0 - Your file appears not to be a valid OLE2 document

🖨 🚪