VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This technical tip shows how use Aspose.Cells for converting XLS files (that contain images, charts

by Aspose (4 Submissions)
Category: Files/File Controls/Input/Output
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Tue 23rd August 2011
Date Added: Mon 8th February 2021
Rating: (1 Votes)

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



 
//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
 


Download this snippet    Add to My Saved Code

This technical tip shows how use Aspose.Cells for converting XLS files (that contain images, charts Comments

No comments have been posted about This technical tip shows how use Aspose.Cells for converting XLS files (that contain images, charts. Why not be the first to post a comment about This technical tip shows how use Aspose.Cells for converting XLS files (that contain images, charts.

Post your comment

Subject:
Message:
0/1000 characters