在VS中添加DevExpress Document Server:[1]

2025-10-23 15:15:44

1、打开Visual Studio,然后通过选择醒薪FILE-New-Project…,创建一个新的Windows Forms Application项目。

在VS中添加DevExpress Document Server:[1]

2、添加以下库为引用:DevExpress.Data.v13.1.dll、 DevExpress.Docs.v13.1.dll、

DevExpress.Office.v13.1.Core.dll、 DevExpress.Spreadsheet.v13.1.Core.dll和DevExpress.Utils.v13.1.dll。

在VS中添加DevExpress Document Server:[1]

3、其实集成步骤在上一部已经完成了,接霸耻下来用个小例子为搁牺轿大家展示下简单的功能。使用以下代码:

using DevExpress.Spreadsheet;

// ...

// Create an instance of a workbook.

Workbook workbook = new DevExpress.Spreadsheet.Workbook();

// Access the first worksheet in the workbook.

Worksheet worksheet = workbook.Worksheets[0];

// Access the "A1" cell in the worksheet.

Cell cell = worksheet.Cells["A1"];

// Specify the "A1" cell value.

cell.Value = 1;

// Fill cells with sequential numbers by using shared formulas.

worksheet.Range["A2:A10"].Formula = "=SUM(A1+1)";

worksheet.Range["B1:B10"].Formula = "=A1+2";

// Multiply values contained in the cell range A1 through A10

// by the corresponding values contained in B1 through B10,

// and display the results in cells C1 through C10.

worksheet.Cells["C1"].CreateArrayFormula("=A1:A10*B1:B10", 10, 1);

// Save the document file under the specified name.

workbook.SaveDocument("TestDoc.xlsx", DocumentFormat.OpenXml);

// Display gridlines in PDF.

worksheet.PrintOptions.PrintGridlines = true;

// Export the document to PDF.

workbook.ExportToPdf("TestDoc.pdf");

// Open the PDF document using the default viewer..

System.Diagnostics.Process.Start("TestDoc.pdf");

// Open the XLSX document using the default application.

System.Diagnostics.Process.Start("TestDoc.xlsx");

4、运行项目,下图就是执行了以上代码后生成的文件。

在VS中添加DevExpress Document Server:[1]

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢