[
https://issues.apache.org/jira/browse/NIFI-2613?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15868891#comment-15868891
]
ASF GitHub Bot commented on NIFI-2613:
--------------------------------------
Github user jvwing commented on the issue:
https://github.com/apache/nifi/pull/929
@jdye64 I'm still confused by the disparity between the annotation docs and
the behavior of the processor, especially with respect to multiple sheets in
the incoming spreadsheet. From the annotations:
> Each sheet from the incoming Excel document will generate a new Flowfile
that will be output from this processor
This was not my experience, and I believe the single call to
`session.clone` on line 143, not performed in a loop, guarantees only a single
flowfile to the success relationship.
> @WritesAttribute(attribute="sheetname", description="The name of the
Excel sheet that this particular row of data came from in the Excel document")
But it has always been `UNKNOWN` for my tests.
---
I created a unit test to help clarify how this is supposed to work. From
the docs, I believe the test below should pass, although it currently fails.
Am I misunderstanding?
Also see
[branch](https://github.com/jvwing/nifi/tree/NIFI-2613-poi-excel-3-tests)
[TwoSheets.xlsx](https://github.com/apache/nifi/files/778759/TwoSheets.xlsx)
@Test
public void testMultipleSheetsGeneratesMultipleFlowFiles() throws
Exception {
testRunner.enqueue(new
File("src/test/resources/TwoSheets.xlsx").toPath());
testRunner.run();
testRunner.assertTransferCount(ConvertExcelToCSVProcessor.SUCCESS,
2);
testRunner.assertTransferCount(ConvertExcelToCSVProcessor.ORIGINAL,
1);
testRunner.assertTransferCount(ConvertExcelToCSVProcessor.FAILURE,
0);
MockFlowFile ffSheetA =
testRunner.getFlowFilesForRelationship(ConvertExcelToCSVProcessor.SUCCESS).get(0);
Long rowsSheetA = new
Long(ffSheetA.getAttribute(ConvertExcelToCSVProcessor.ROW_NUM));
assertTrue(rowsSheetA == 4l);
assertTrue(ffSheetA.getAttribute(ConvertExcelToCSVProcessor.SHEET_NAME).equalsIgnoreCase("TestSheetA"));
MockFlowFile ffSheetB =
testRunner.getFlowFilesForRelationship(ConvertExcelToCSVProcessor.SUCCESS).get(1);
Long rowsSheetB = new
Long(ffSheetB.getAttribute(ConvertExcelToCSVProcessor.ROW_NUM));
assertTrue(rowsSheetB == 3l);
assertTrue(ffSheetB.getAttribute(ConvertExcelToCSVProcessor.SHEET_NAME).equalsIgnoreCase("TestSheetB"));
}
> Support extracting content from Microsoft Excel (.xlxs) documents
> -----------------------------------------------------------------
>
> Key: NIFI-2613
> URL: https://issues.apache.org/jira/browse/NIFI-2613
> Project: Apache NiFi
> Issue Type: New Feature
> Components: Extensions
> Reporter: Jeremy Dyer
> Assignee: Jeremy Dyer
>
> Microsoft Excel is a wildly popular application that businesses rely heavily
> on to store, visualize, and calculate data. Any single company most likely
> has thousands of Excel documents containing data that could be very valuable
> if ingested via NiFi and combined with other datasources. Apache POI is a
> popular 100% Java library for parsing several Microsoft document formats
> including Excel. Apache POI is extremely flexible and can do several things.
> This issue would focus solely on using Apache POI to parse an incoming .xlxs
> document and convert it to CSV. The processor should be capable of limiting
> which excel sheets. CSV seems like the natural choice for outputting each row
> since this feature is already available in Excel and feels very natural to
> most Excel sheet designs.
> This capability should most likely introduce a new "poi" module as I envision
> many more capabilities around parsing Microsoft documents could come from
> this base effort.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)