Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: Tim MeagherHey,
As Andy points out, adding additional output pins for the sheets you want to extract allows you to extract more than one sheet per workbook.
It's worth pointing out that you don't even need to configure the WorkbookSpec in order to achieve this.
If you have two output pins, and two worksheets in the workbook, the node will automatically extract the data from the worksheets to the node's outputs.
The node looks at all of the worksheets in the workbook and try and map them to the node outputs.
If a WorkbookSpec parameter is present, then the node will only extract the data and worksheets that are specifically referenced in the WorkbookSpec parameter.
Otherwise, it looks at each of the worksheets, and attempts to locate outputs with the same name as the worksheets.
If it sees a worksheet with the same name as an output, then that worksheet will be written to the corresponding output.
If the number of worksheets in the Excel files are variable - i.e. you don't know the number of worksheets in advance - then you can construct an output to handle all of these.
Simply create a new output on the node, give it some name e.g. "Additional Worksheets", and then set the value of the "MetadataOutputPin" parameter to the name of that output.
If this is done, then if there are more worksheets than there are outputs (aside from the output referenced in the "MetadataOutputPin" parameter), then each of those worksheets will be written to a separate BRD file, and a record will be written to the output referenced in the "MetadataOutputPin" parameter - referencing the location of the BRD file.
If, instead, you want to use the WorkbookSpec parameter, then it is possible to reference
either by the index of the worksheet in the workbook, or by the name.
It is also possible to use an empty "<sheet/>" tag, which will simply get the "next" worksheet - assuming that you have not attempted to extract any worksheets by name prior to the "<sheet/>" tag.
Consider the WorkbookSpec you have used:
<workbook>
<sheet/>
<sheet index="2" />
</workbook>
Here, the first "<sheet/>" element means that the "next" worksheet within the workbook should be extracted.
Since no other sheets have been specified, this would be the first sheet in the workbook.
Then, the line
would extract the second worksheet in the Excel workbook.
However, if you do not have an additional output pin on the node to handle the second worksheet, then the worksheet will not be written.
If you simply wanted to extract only the second worksheet from the Excel file, and write this to the node's output - without constructing any additional outputs, you could use:
<workbook>
<sheet index="2" />
</workbook>
Hope this helps,
Tim.