using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Aspose.Cells;
using Aspose.Cells.Rendering;
public void ExcelTopngImg(string xlsFile,string picFile)
{
Workbook book = new Workbook(xlsFile);
Worksheet sheet = book.Worksheets[0];
sheet.PageSetup.LeftMargin = 0;
sheet.PageSetup.RightMargin = 0;
sheet.PageSetup.BottomMargin = 0;
sheet.PageSetup.TopMargin = 0;
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
//imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
imgOptions.OnePagePerSheet = true;
imgOptions.PrintingPage = PrintingPageType.IgnoreBlank;
SheetRender sr = new SheetRender(sheet, imgOptions);
sr.ToImage(0, picFile);
}
学习更多加资料
