Home >
.NET Imaging SDK >
C# >
Specify Excel Rendering Options
If this is your first time to use our DocImageSDK, we strongly suggest you reading How to Start first!
Customize C# Excel Rendering Process
Apart from the capacity to complete basic Excel to document or image converting process, this .NET Excel converting control SDK also enables C# developers to customize Excel converting and rendering process.
c# itextsharp pdf page to image,
add image to pdf using itextsharp vb.net,
excel to pdf using itextsharp in c#,
vb.net pdfreader class,
asp.net mvc 5 generate pdf,
c# code 128 algorithm.
For example, you can specify the resolution/size of converted image. You can set different conversion modes, like batch conversion or page-by-page conversion.
Related .net document control helps:
asp.net mvc text file viewer: ASP.NET Text file viewer in MVC, WebForms: Open, view, annotate, convert txt files in C# ASP.NET
asp.net edit pdf image control:
ASP.NET PDF Image Edit Control: online insert, edit PDF images in C#
asp.net annotate pdf control:
ASP.NET Annotate PDF Control: annotate, comment, markup PDF document online using ASP.NET C#
asp.net document viewer control:
EdgeDoc:ASP.NET Document Viewer C# Control:
Open, view, annotate, redact, convert documents online in C#, VB.NET, AS...
mvc pdf editor: ASP.NET MVC PDF Viewer & Editor: view, annotate, redact, edit PDF document in C# ASP.NET MVC
asp.net pdf viewer control: ASP.NET PDF Viewer Control: view, navigate, zoom Adobe PDF document in C# ASP.NET
document viewer asp.net c#: ASP.NET Document Viewer using C#: Open, View, Annotate, Redact, Convert document files in ASP.NET using C#, HTML5, JQuer...
Sometimes, based on different project requirements, C# developers may need to convert Excel document file to image file with desired imaging properties. In order to help developers solve this problem, we offer this online tutorial page. It will guide you to create a featured C# Excel converting application by setting Excel rendering parameters.
convert tiff to pdf c# itextsharp,
reduce pdf file size in c#,
c# convert pdf to svg,
how to edit pdf file in vb.net,
c# pdf stamp,
convert csv to pdf c# itextsharp,
c# pdf add background.
Set C# Excel Rendering Options with Different APIs
In this section, we mainly introduce some suggestions for setting Excel document rendering options in different situations.
C#: Set Width and Height of Original Excel Page
Before you convert any Excel document sheet/page in C#.NET program, you may use these two APIs to get the width and height of the original Excel sheet/page in inches.
- XLSXPage.GetWidth();
- XLSXPage.GetHeight();
C#: Use These APIs If Your Image Size Is Known
If you already know your target image dimension and the target size is not too big, the following APIs are better choices. Here we also provide C#.NET demo code for this situation.
REImage ConvertToImage(Size targetSize);
Bitmap GetBitmap(float zoomValue);
Bitmap GetBitmap(Rectangle sourceRectangle, Size targetSize);
public static void ExcelToImageWithSpecifiedSize(Size size)
{
// load Excel document
XLSXDocument doc = new XLSXDocument(@"c:\sample.xlsx");
// compute zoom out factor
// get the first page as sample page
XLSXPage page = (XLSXPage)doc.GetPage(0);
// the orignial height and width are measured at 96 dpi
float originalWidth = page.GetWidth() * 96;
float originalHeight = page.GetHeight() * 96;
// get the image which sources the whole page and targets the specified size
page.GetBitmap(new Rectangle(0, 0, (int)originalWidth, (int)originalHeight), size);
// or specify dimension with a fixed ratio between the orignal and the target, with width set to the target width and height be adjusted accordingly
page.GetBitmap(size.Width / originalWidth);
}
C#: Set Excel Rendering in Partitions
If your Excel spreadsheet is too big to handle using a single Bitmap Object in C#.NET due to memory limit and performance concern, you are supposed to render and convert it in partitions. And below are the APIs and demo code for this situation.
REImage CropImage(Rectangle sourceRegion, Size targetSize);
Bitmap GetBitmap(Rectangle sourceRectangle, Size targetSize);
void Draw(Graphics g, PointF loaction, Rectangle sourceRectangle, Size targetSize);
// load Excel document
XLSXDocument doc = new XLSXDocument(@"c:\sample.docx");
// get the first page as sample page
XLSXPage page = (XLSXPage)doc.GetPage(0);
// the orignial height and width are measured at 96 dpi of this page
float originalWidth = page.GetWidth() * 96;
float originalHeight = page.GetHeight() * 96;
// if the dimension is too big, divide it into partitions
// in this example, we divide Excel sheet into 2
// get bitmap of top half of the sheet without resizing
page.GetBitmap(new Rectangle(0, 0, (int)(originalWidth), (int)(originalHeight / 2)), new Size((int)(originalWidth ), (int)(originalHeight / 2)));
Note that, the source region is in pixel and is measured using 96 default resolution. The original dimension of Excel document page can be computed using widthInPixel = page.GetWidth()*96 and heightInPixel= page.GetHeight()*96. For example, to convert the top half of Excel page to image, you can set the source rectangle to start at (0, 0) and with the original width and half of the original height.
C#: Render Whole Excel Document to Images at a Time
To convert the whole Excel document to images at a time, you may use the following APIs in XLSXDocument.
void ConvertToImages(ImageType target, String directory, String fileName);
void ConvertToImages(ImageType targetType, float zoomValue, String directory, String fileName);
Other Related C# Excel Converting Tutorials
Specifying C# Excel rendering parameters is only a part of Excel converting process. And here we just briefly illustrate some general settings for
C# Excel converting. If you want to see other C#.NET tutorials, please follow the attached links.
- Render desired Excel sheet to REImage object in C#: to complete C# Excel converting, you need to create an image object (REImage) as an Excel converting intermediate frist;
- Then, convert created REImage to desired file: as this .NET Excel Converting SDK supports some popular documents and images, you can save created image object/collection to these file formats, like PDF, TIFF, SVG and some raster image files.
Recommend this to Google+