This technical tip shows how use Aspose.Cells for converting XLS files (that contain images, charts
This technical tip shows how use Aspose.Cells for converting XLS files (that contain images, charts etc.) to PDF documents.If you need to save
Rate This technical tip shows how use Aspose.Cells for converting XLS files (that contain images, charts
(1(1 Vote))
//Get the Excel file path
string filePath = @"e:\test\Book1.xls";
//Instantiage a new workbook and open the Excel
//File from its location
Workbook workbook = new Workbook(filePath);
//Get the count of the worksheets in the workbook
int sheetCount = workbook.Worksheets.Count;
//Make all sheets invisible except first worksheet
for (int i = 1; i < workbook.Worksheets.Count; i++)
{
workbook.Worksheets[i].IsVisible = false;
}
//Take Pdfs of each sheet
for (int j = 0; j < workbook.Worksheets.Count; j++)
{
Worksheet ws = workbook.Worksheets[j];
workbook.Save("e:\\test2\\worksheet-" + ws.Name + ".pdf");
if (j < workbook.Worksheets.Count - 1)
{
workbook.Worksheets[j + 1].IsVisible = true;
workbook.Worksheets[j].IsVisible = false;
}
}
[VB]
'Get the Excel file path
Dim filePath As String = "e:\test\Book1.xls"
'Instantiage a new workbook and open the Excel
'File from its location
Dim workbook As New Workbook(filePath)
'Get the count of the worksheets in the workbook
Dim sheetCount As Integer = workbook.Worksheets.Count
'Make all sheets invisible except first worksheet
For i As Integer = 1 To workbook.Worksheets.Count - 1
workbook.Worksheets(i).IsVisible = False
Next i
'Take Pdfs of each sheet
For j As Integer = 0 To workbook.Worksheets.Count - 1
Dim ws As Worksheet = workbook.Worksheets(j)
workbook.Save("e:\test2\worksheet-" & ws.Name & ".pdf")
If j < workbook.Worksheets.Count - 1 Then
workbook.Worksheets(j + 1).IsVisible = True
workbook.Worksheets(j).IsVisible = False
End If
Next j
This technical tip shows how use Aspose.Cells for converting XLS files (that contain images, charts Comments
No comments yet — be the first to post one!
Post a Comment