1
Excel to PDF conversion with choice of sheet/tab rather than all
Idea shared by Tony Phan - 1/11/2017 at 6:20 AM
Completed
This should be an easy implementation since we already have the input/output options.  Right now, the converter does an excellent job of converting Excel to PDF, however, it's outputting every sheet in the workbook into a single PDF output.  The trouble is, most often, for a workbook, we only want 1 sheet to print, the rest are merely data to support the 1 sheet.  Some books can have 10 sheets or more, which results in a huge PDF output that's unnecessary.  For now, what we have to do as a work-around is to rely on Excel to do an Export to PDF for specific pages, we hope to be able to use DocumentUltimate entirely.

1 Reply

Reply to Thread
0
Cem Alacayir Replied
Employee Post
FYI, this now implemented with DocumentUltimate v2.5.0:
 

Added: SpreadsheetInputOptions class for prodiving spreadsheet format specific options. For example setting property RenderColumnsFitToPages = 1, will make all columns of a spreadsheet fit to the same page. SheetRange property allows you to choose specific sheet numbers or predefined keywords like (works similar to PageRange class):

  • "all" -> keyword representing all sheet numbers.

  • "active" -> keyword representing the active sheet number.

  • "visible" -> keyword representing visible sheet numbers.

SpreadsheetInputOptions class has many other options related to rendering of spreadsheets.

So now you can choose which sheets to output:
 
var inputOptions = new SpreadsheetInputOptions
{
	//Only visible sheets
	OutputSheetRange = new SheetRange("visible"), 
	
	//All columns of a spreadsheet should fit to the same page (do not break)
	RenderColumnsFitToPages = 1 
};

DocumentUltimate.DocumentConverter.Convert(inputDocument, inputOptions, outputDocument);
 
The new SheetRange class is similar to PageRage class:
 

The range is specified as a string in the following forms or combination thereof:

5 single value
1,2,3,4,5 sequence of values
1-5 closed range
-5 open range (converted to a sequence from 1 to 5)
1- open range (converted to a sequence from 1 to final sheet)
all keyword representing all sheet numbers.
odd keyword representing odd sheet numbers.
even keyword representing even sheet numbers.
active keyword representing the active sheet number.
visible keyword representing visible sheet numbers.

The value delimiter can be either ',' or ';' and the range separator can be either '-' or ':'. Whitespace is permitted at any point in the input.

Any elements of the sequence that contain non-digit, non-whitespace, or non-separator characters or that are empty are ignored.

Usage examples:

//Only the active sheet
OutputSheetRange = new SheetRange("active"), 

//Only first sheet
OutputSheetRange = new SheetRange("1"), 

//Only sheets 1, 2 and 3
OutputSheetRange = new SheetRange("1-3"), 

 

Reply to Thread