打印的Excel在C#(使用的SpreadsheetGear生成) [英] Print excel (generated using Spreadsheetgear) in C#

查看:1440
本文介绍了打印的Excel在C#(使用的SpreadsheetGear生成)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#我在特定的格式生成一个excel,我要打印click_print同一个Excel格式。

In c# i am generating an excel in specific format, i have to print the same excel format on click_print.

PS-的Microsoft Office无法使用,使用的SpreadsheetGear进行这一点。

P.s.-Microsoft Office not available,using SpreadSheetGear for this.

推荐答案

我查电子书籍的回答,如果你有一个用户界面,并利用WorkbookView控制。如果你没有一个UI生成此工作簿中的代码,你也可以使用的 WorkbookPrintDocument 类。下面是说明了这一点在控制台应用程序的示例:

I recomment Chuck's answer if you have a UI and are utilizing the WorkbookView control. If you are generating this workbook in-code without a UI, you can also print a workbook by using the WorkbookPrintDocument class. Below is an example that demonstrates this in a console application:

using SpreadsheetGear;
using SpreadsheetGear.Printing;
using SpreadsheetGear.Drawing.Printing;

static void Main(string[] args)
{
    // Create a workbook with some cell data
    IWorkbook workbook = Factory.GetWorkbook();
    IWorksheet worksheet = workbook.ActiveWorksheet;
    IRange cells = worksheet.Cells;
    cells["A1:D10"].Value = "=RAND()";

    // Create a WorkbookPrintDocument.  
    WorkbookPrintDocument printDocument = new WorkbookPrintDocument(worksheet, PrintWhat.Sheet);

    // Set the printer if necessary...let's go old school.
    printDocument.PrinterSettings.PrinterName = "Epson MX-80";

    // Print it
    printDocument.Print();
}

如果您使用的是2012的SpreadsheetGear的.NET 4.0版本,你会需要添加一个引用到SpreadsheetGear2012.Drawing.dll装配访问SpreadsheetGear.Drawing.Printing命名空间。

If you are using the .NET 4.0 build of SpreadsheetGear 2012, you'll need to add a reference to the SpreadsheetGear2012.Drawing.dll assembly to access the SpreadsheetGear.Drawing.Printing namespace.

另外请注意,我指定要打印(的使用范围),通过PrintWhat.Sheet板材。见SpreadsheetGear.Printing。 PrintWhat 枚举了更多的选择。

Also note that I specify to print (the used range of) the sheet via PrintWhat.Sheet. See the SpreadsheetGear.Printing.PrintWhat enum for more options.

这篇关于打印的Excel在C#(使用的SpreadsheetGear生成)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆