Allows to specify custom sheets from Excel workbook for converting

Namespace:  SautinSoft
Assembly:  UseOffice (in UseOffice.dll) Version: 4.3.12.15

Syntax

      
 C#  Visual Basic 
public class CSheet
Public Class CSheet

Members

         
 All Members  Constructors   Methods  
 Public

 Protected
 Instance

 Static 
 Declared

 Inherited
 XNA Framework Only 

 .NET Compact Framework Only 

 MemberDescription
UseOffice..::.CSheet()()()
Creates object of class CSheet. By default all sheets from workbook will be converted
All()()()
Convert all sheets from workbook
Custom(Int32)
Allows to set custom sheet for converting by its number
Custom(array<Int32>[]()[])
Allows to specify custom sheets to convert by their numbers
Custom(array<String>[]()[])
Allows to specify custom sheets to convert by their names
Range(Int32, Int32)
Allows to specify custom sheets from X to Y

Remarks

Examples

CopyHow to convert custom Excel sheets to a PDF document in C#
using System;
using System.IO;
using System.Collections;

namespace Sample
{
    class Test
    {

        static void Main(string[] args)
        {

            //Convert Excel file to PDF file
            //If you need more information about UseOffice .Net email us at:
            //support[at]sautinsoft.com        


            SautinSoft.UseOffice u = new SautinSoft.UseOffice();

            //Path to any local file
            string inputFilePath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(),@"..\..\..\..\..\..\Testing files\Excel.xlsx"));
            //Path to output resulted file
            string outputFilePath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(),@"..\..\..\..\..\..\Testing files\Result.pdf"));

            //Prepare UseOffice .Net, loads MS Excel in memory
            int ret = u.InitExcel();            

            //Return values:
            //0 - Loading successfully
            //1 - Can't load MS Excel library in memory 

            if (ret==1)
                return;

            //Set to convert only 1st and 3rd sheets
            u.Sheets.Custom(new int [] {1,3});

            //Converting
            ret = u.ConvertFile(inputFilePath, outputFilePath, SautinSoft.UseOffice.eDirection.XLSX_to_PDF);

            //Release MS Excel from memory
            u.CloseExcel();

            //0 - Converting successfully
            //1 - Can't open input file. Check that you are using full local path to input file, URL and relative path are not supported
            //2 - Can't create output file. Please check that you have permissions to write by this path or probably this path already used by another application
            //3 - Converting failed, please contact with our Support Team
            //4 - MS Office isn't installed. The component requires that any of these versions of MS Office should be installed: 2000, XP, 2003, 2007 or 2010
            if(ret==0 )
            {
                //Show produced file
                System.Diagnostics.Process.Start(outputFilePath);
            }        
        }
    }
}
CopyHow to convert custom Excel sheets to a PDF document in VB.Net
Imports System
Imports System.IO
Imports System.Text
Imports System.Collections


Module Module1
    Sub Main()
        'Convert custom Excel sheets to PDF file
        'If you need more information about UseOffice .Net email us at:
        'support[at]sautinsoft.com        



        Dim u As New SautinSoft.UseOffice

        'Path to any local file
        Dim inputFilePath As String = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "..\..\..\..\..\Testing files\Excel.xlsx"))
        'Path to output resulted file
        Dim outputFilePath As String = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "..\..\..\..\..\Testing files\Result.pdf"))

        'Prepare UseOffice .Net, loads MS Excel in memory
        Dim ret As Integer = u.InitExcel()

        'Return values:
        '0 - Loading successfully
        '1 - Can't load MS Excel library in memory 


        If ret = 1 Then
            Return
        End If

        'Set to convert only 1st and 3rd sheets
        u.Sheets.Custom(New Integer() {1, 3})

        'Converting
        ret = u.ConvertFile(inputFilePath, outputFilePath, SautinSoft.UseOffice.eDirection.XLSX_to_PDF)

        'Release MS Excel from memory
        u.CloseExcel()

        '0 - Converting successfully
        '1 - Can't open input file. Check that you are using full local path to input file, URL and relative path are not supported
        '2 - Can't create output file. Please check that you have permissions to write by this path or probably this path already used by another application
        '3 - Converting failed, please contact with our Support Team
        '4 - MS Office isn't installed. The component requires that any of these versions of MS Office should be installed: 2000, XP, 2003, 2007 or 2010
        If ret = 0 Then
            'Show produced file
            System.Diagnostics.Process.Start(outputFilePath)
        End If
    End Sub
End Module

Inheritance Hierarchy

System..::.Object
  SautinSoft..::.UseOffice..::.CSheet

See Also