Codecs: How to convert pages of XLSX document to the PNG files?
In This Topic
SDK can convert pages of XLSX/XLS document to the raster images and save rendered images to the image files.
Here is C#/VB.NET code that shows how to convert pages of XLSX document to the PNG files:
/// <summary>
/// Converts pages of XLSX document to PNG files.
/// </summary>
public static void ConvertXlsxToPng(string xlsxFileName)
{
// create image collection
using (Vintasoft.Imaging.ImageCollection images = new Vintasoft.Imaging.ImageCollection())
{
// add XLSX document to the image collection
images.Add(xlsxFileName);
// create PNG encoder
using (Vintasoft.Imaging.Codecs.Encoders.PngEncoder pngEncoder =
new Vintasoft.Imaging.Codecs.Encoders.PngEncoder())
{
// for each page in XLSX document
for (int i = 0; i < images.Count; i++)
{
// save rendered image to a PNG file
images[i].Save(string.Format("page{0}.png", i), pngEncoder);
}
}
// dispose images
images.ClearAndDisposeItems();
}
}
''' <summary>
''' Converts pages of XLSX document to PNG files.
''' </summary>
Public Shared Sub ConvertXlsxToPng(xlsxFileName As String)
' create image collection
Using images As New Vintasoft.Imaging.ImageCollection()
' add XLSX document to the image collection
images.Add(xlsxFileName)
' create PNG encoder
Using pngEncoder As New Vintasoft.Imaging.Codecs.Encoders.PngEncoder()
' for each page in XLSX document
For i As Integer = 0 To images.Count - 1
' save rendered image to a PNG file
images(i).Save(String.Format("page{0}.png", i), pngEncoder)
Next
End Using
' dispose images
images.ClearAndDisposeItems()
End Using
End Sub