UseOfficeExcelOptions Property |
Allows to specify some Excel options (sheet numbers, how to fit a sheet on page) for converting.
Namespace: SautinSoftAssembly: UseOffice (in UseOffice.dll) Version: 2024.12.12
Syntax public UseOfficeCExcelOptions ExcelOptions { get; set; }
Public Property ExcelOptions As UseOfficeCExcelOptions
Get
Set
Property Value
UseOfficeCExcelOptionsRemarks You may specify: all, even, odd and custom sheets. For example:
Example How 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)
{
SautinSoft.UseOffice u = new SautinSoft.UseOffice();
string inpFile = Path.GetFullPath(@"..\..\..\..\..\..\TestFiles\example.xlsx");
string outFile = Path.GetFullPath("Result.pdf");
int ret = u.InitExcel();
if (ret == 1)
{
Console.WriteLine("Error! Can't load MS Excel library in memory.");
return;
}
u.ExcelOptions.SheetNumbers(new int [] {1,3});
ret = u.ConvertFile(inpFile, outFile, SautinSoft.UseOffice.eDirection.XLSX_to_PDF);
u.CloseExcel();
if (ret == 0)
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile) { UseShellExecute = true });
}
else
Console.WriteLine("Error! Please contact with SautinSoft support: support@sautinsoft.com.");
}
}
}
How to convert custom Excel sheets to a PDF document in VB.Net
Imports System
Imports System.IO
Imports System.Collections
Namespace Sample
Friend Class Test
Shared Sub Main(ByVal args() As String)
Dim u As New SautinSoft.UseOffice()
Dim inpFile As String = Path.GetFullPath("..\..\..\..\..\..\TestFiles\example.xlsx")
Dim outFile As String = Path.GetFullPath("Result.pdf")
Dim ret As Integer = u.InitExcel()
If ret = 1 Then
Console.WriteLine("Error! Can't load MS Excel library in memory.")
Return
End If
u.ExcelOptions.SheetNumbers(New Integer() {1, 3})
ret = u.ConvertFile(inpFile, outFile, SautinSoft.UseOffice.eDirection.XLSX_to_PDF)
u.CloseExcel()
If ret = 0 Then
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(outFile) With {.UseShellExecute = True})
Else
Console.WriteLine("Error! Please contact with SautinSoft support: support@sautinsoft.com.")
End If
End Sub
End Class
End Namespace
See Also