question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SelectSheetsForStreamingPoiTransformer not working correctly

See original GitHub issue

Hi,

I am using the example here: https://github.com/jxlsteam/jxls/blob/master/jxls-poi/src/test/java/org/jxls/examples/stress/SxssfDemo.java

method: simpleSxssf()

I am trying to use the SelectSheetsForStreamingPoiTransformer like this:

I copy the sheet “Template” into a second sheet “NoStreaming”. I adapt the method simpleSxssf() to only stream the “Template” sheet:

Context context = new Context();
context.putVar("cellRefUpdater", new CellRefUpdater());
context.putVar("employees", employees);
context.getConfig().setIsFormulaProcessingRequired(false);
Workbook workbook = WorkbookFactory.create(is);
SelectSheetsForStreamingPoiTransformer transformer = new SelectSheetsForStreamingPoiTransformer(workbook);
Set<String> streamingSheets = new HashSet<>();
streamingSheets.add("Template");
transformer.setDataSheetsToUseStreaming(streamingSheets);
//transformer.setEvaluateFormulas(true); // used with newest JXLS version
processTemplate(context, transformer);
workbook.write(os);
private void processTemplate(Context context, Transformer transformer) {
        XlsCommentAreaBuilder areaBuilder = new XlsCommentAreaBuilder();
        areaBuilder.setTransformer(transformer);
        List<Area> xlsAreaList = areaBuilder.build();
        for (Area xlsArea : xlsAreaList) {
            xlsArea.applyAt(new CellRef(xlsArea.getStartCellRef().getCellName()), context);
        }
    }

but I am getting the outputs in the screenshot. What is going wrong here?

Using jxls 2.8.1

Bildschirmfoto 2020-06-08 um 14 11 13 Bildschirmfoto 2020-06-08 um 14 11 04

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
edu-decommented, Jun 22, 2020

Ok, for completeness, this code seems to work for SelectSheetsForStreamingPoiTransformer:

Context context = new Context();
            	context.putVar("employees", employees);
            	context.putVar("departments", departments);
            	
            	Workbook workbook = WorkbookFactory.create(is);
            	SelectSheetsForStreamingPoiTransformer transformer = new SelectSheetsForStreamingPoiTransformer(workbook);
            	Set<String> streamingSheets = new HashSet<>();
            	
            	int nrSheets = workbook.getNumberOfSheets();
            	for ( int i = 0; i < nrSheets; i++ ) {
            		streamingSheets.add(workbook.getSheetName( i ));
            	}
            	transformer.setDataSheetsToUseStreaming(streamingSheets);
            	processTemplate(context, transformer);
            	transformer.getWorkbook().write(os);
            	if (transformer.getWorkbook() instanceof SXSSFWorkbook) {
                    ((SXSSFWorkbook) transformer.getWorkbook()).dispose();
            	}
0reactions
edu-decommented, Jun 22, 2020

Hi SoltauFintel ,

how exactly do you mean this? transformer.getWorkbook(); only gives a workbook back. So where to use this workbook in the code ?

context.putVar("cellRefUpdater", new CellRefUpdater());
context.getConfig().setIsFormulaProcessingRequired(false);
Workbook workbook = WorkbookFactory.create(is);
SelectSheetsForStreamingPoiTransformer transformer = new SelectSheetsForStreamingPoiTransformer(workbook);
Workbook w = transformer.getWorkbook(); // what to do with this workbook ?
 Set<String> streamingSheets = new HashSet<>();
streamingSheets.add("Template");
transformer.setDataSheetsToUseStreaming(streamingSheets);
//transformer.setEvaluateFormulas(true); // used with newest JXLS version
processTemplate(context, transformer);
workbook.write(os);
Read more comments on GitHub >

github_iconTop Results From Across the Web

JXLS - how to write data to workbook in batches - Stack Overflow
I have to implement export of users into XLS. After a little research JXLS came up as simple solution, but there is one...
Read more >
Version History - JXLS - - SourceForge
9.0. With this version we migrated from BitBucket to Github. A list of resolved issues. #1: Javadoc · #2: moved jxls ...
Read more >
leonate / jxls / issues - Bitbucket
Title T P Status Assignee Version Creat... #164: Remove jexcel task minor resolved 2.7.0 2019... #140: Mono repo jxls‑demo into jxls · jxls task major...
Read more >
FIND not working in Excel? Which one was your problem?
00:00 FIND not finding something that is there00:15 FIND not looking in the correct area00:52 FIND looking IN the formula NOT the resultant ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found