The process for loading Excel documents with ImageGear is very similar to that of other document formats. The following steps will enable you to view the first page of a worksheet in an Excel document.
Add the Excel format to the list of file format filters ImageGear will use to detect formats of loaded content.
Once the desired Excel file has been opened into a System.IO.Stream, the document can be loaded with the LoadDocument method. The startPageNumber and count parameters of the LoadDocument method can be used to load a select few or all of the sheets in the Excel document. The example below will load all available sheets.
The GetPageCount method can be used to get the number of sheets in a Stream that contains a valid Excel document.
Once the document is loaded, the top-level ImGearExcelBookDocument will contain pages, with each one representing an entire sheet. Retrieve one of the pages to access a sheet in the Excel document that can be displayed or printed as a single page or paginated further with a different page size. The following example paginates the worksheet into pages whose size is determined by that which is defined in the original Excel document. Alternatively, a custom size can be defined for the new pages simply by setting the width and height parameters of the Repaginate method accordingly.
Displaying the first one of the pages you created for the sheet is easy using ImageGear’s PageView control. Simply create the control and set the Page property to that of the Excel page. Refer to the Displaying Images topic for more information on displaying images with ImageGear.