谢岗网站仿做,返利网站做鹊桥推广,音乐自助建站,上海杨浦区建设网站DevExpress Office File API是一个专为C#, VB.NET 和 ASP.NET等开发人员提供的非可视化.NET库。有了这个库#xff0c;不用安装Microsoft Office#xff0c;就可以完全自动处理Excel、Word等文档。开发人员使用一个非常易于操作的API就可以生成XLS, XLSx, DOC, DOCx, RTF, CS…DevExpress Office File API是一个专为C#, VB.NET 和 ASP.NET等开发人员提供的非可视化.NET库。有了这个库不用安装Microsoft Office就可以完全自动处理Excel、Word等文档。开发人员使用一个非常易于操作的API就可以生成XLS, XLSx, DOC, DOCx, RTF, CSV 和 Snap Report等企业级文件。
DevExpress Office File API控件日前正式发布了v24.1新版本正式官宣支持Unix系统的打印、增强了可访问性等欢迎下载最新版组件体验
DevExpress v24.1正式版下载(Q技术交流532598169)
基于Unix系统的打印
在这个版本(v24.1)中官方为运行在基于Unix系统上的基于.NET Office File API驱动的应用程序增加了打印支持现在可以在非Windows环境中打印条码、Word、Excel和PDF文档。
新版本创建了一组新的API与 DevExpress.Drawing 库中可用的DXPrinterSettings选项一起工作。
使用以下新方法在基于Unix的系统上打印文档和条形码
C#
// DevExpress.XtraRichEdit.RichEditDocumentServer:
public void Print(DXPrinterSettings printerSettings, string printDocumentName);
public void Print(DXPrinterSettings printerSettings);//DevExpress.Spreadsheet.Workbook:
public void Print(DXPrinterSettings printerSettings);
public void Print(DXPrinterSettings printerSettings, params string[] sheetNames);
public void Print(DXPrinterSettings printerSettings, IEnumerablestring sheetNames);//DevExpress.BarCodes.BarCode:
public void Print(DXPrinterSettings printerSettings);
对于DevExpress.Pdf.PdfDocumentProcessor类您仍然需要调用当前的Print(PdfPrinterSettings printerSettings)方法。要修改打印设置请使用新的PdfPrinterSettings.DXPrinterSettings选项如下
C#
using DevExpress.Drawing.Printing;
using DevExpress.Pdf;// Load a PDF file
PdfDocumentProcessor documentProcessor new PdfDocumentProcessor();
documentProcessor.LoadDocument(..\..\Demo.pdf);// Declare printer settings
PdfPrinterSettings pdfPrinterSettings new PdfPrinterSettings();// Specify CUPS printer settings
DXPrinterSettings dxPrinterSettings pdfPrinterSettings.DXSettings;
dxPrinterSettings.Duplex DXDuplexMode.DuplexLongEdge;
dxPrinterSettings.Copies 3;// Print the document
documentProcessor.Print(pdfPrinterSettings);
注意对于基于Unix的系统您需要单独安装libcups2包。
可访问性增强
在将Word文档导出为可访问的PDF文件时新版本扩展了对以下元素的可访问性相关支持
目录标签元数据字段Alt文本处理表格浮动对象
使用Adobe Acrobat Pro和PDF Accessibility Checker 2024进行质量控制新版本的测试文档成功地通过了PDF/UA兼容性和WCAG 2.1兼容性的验证。
当您PdfUACompatibility选项时与可访问性相关的导出增强功能可以开箱即用
C#
using System.IO;
using DevExpress.XtraRichEdit;
// ...
RichEditDocumentServer wordProcessor new RichEditDocumentServer();
//...
using(FileStream stream
new FileStream(resultFilePath, FileMode.Create, FileAccess.Write, FileShare.Read)) {
PdfExportOptions exportOptions new PdfExportOptions();
exportOptions.PdfUACompatibility PdfUACompatibility.PdfUA1;wordProcessor.ExportToPdf(stream, exportOptions);
}
此外新版本还为Word Processing Shape和Spreadsheet Shape类添加了一个Decorative属性以将文档图形(图片、形状和图表)标记为装饰性的。装饰性的形状增加了视觉上的趣味但它们不能提供信息。因此在生成可访问文档时不需要为装饰性对象指定Alt Text(有意义的描述)。
将文档导出为SVG
新版本扩展了图像导出引擎现在在Barcode Generation API、Word Processing Document API和Spreadsheet Document API库中支持SVG图像。使用v24.1您可以在Windows和非Windows环境中从条形码、Word文档页面和Excel工作表/单元格范围生成SVG图像。
要从条形码生成SVG图像需要创建BarCode类实例根据需要修改设置并使用DXImageFormat.Svg作为参数调用BarCode.Save方法。
C#
using (BarCode barCode new BarCode()) {
barCode.Symbology Symbology.QRCode;
barCode.BackColor Color.White;
barCode.ForeColor Color.Black;
barCode.RotationAngle 0;
barCode.CodeBinaryData Encoding.Default.GetBytes(https://www.devexpress.com/);
barCode.Options.QRCode.CompactionMode QRCodeCompactionMode.Byte;
barCode.Options.QRCode.ErrorLevel QRCodeErrorLevel.Q;
barCode.Options.QRCode.ShowCodeText false;
barCode.DpiX 72;
barCode.DpiY 72;
barCode.Module 2f;barCode.Save(barcode.svg, DXImageFormat.Svg);
}
对于Word文档使用全新的Image Export API - 创建一个RichEditImageExportOptions实例使用RichEditImageExportOptions.Format属性指定目标DXImageFormat.Svg格式并使用RichEditImageExportOptions对象作为参数调用RichEditDocumentServerExtensions.ExportToImage扩展方法。
C#
using (var wordProcessor new RichEditDocumentServer()) {
wordProcessor.LoadDocument(C:\Documents\Alice.docx);
RichEditImageExportOptions options new RichEditImageExportOptions();
options.Format DXImageFormat.Svg;
options.PageRange 1;wordProcessor.Document.ExportToImage(first_page_image.svg, options);
}
要将Excel工作表中的单元格区域导出为SVG图像请使用ImageFileFormat.Svg作为参数调用CellRangeExtensions.ExportToImage方法。
C#
using (Workbook workbook new Workbook()) {
workbook.LoadDocument(InvestmentPortfolio.xlsx, DevExpress.Spreadsheet.DocumentFormat.Xlsx);
Worksheet worksheet workbook.Worksheets.ActiveWorksheet;worksheet.Range[B18:I30].ExportToImage(cell_range_image.svg, ImageFileFormat.Svg);
}
Spreadsheet Document API
对齐和分布式文本对齐
v24.1增加了对电子表格单元格内的水平对齐类型的支持使用这些对齐选项的Excel文件可以打印并导出为PDF。 可以使Cell.Alignment.Horizontal 属性在代码中指定水平对齐方式。
下面的代码片段指定了代码中的对齐方式
C#
var workbook new Workbook();
var worksheet workbook.Worksheets[0];Cell cellA1 worksheet.Cells[A1];
cellA1.Value Justified and top;
cellA1.Alignment.Horizontal SpreadsheetHorizontalAlignment.Justify;
cellA1.Alignment.Vertical SpreadsheetVerticalAlignment.Top;
workbook.ExportToPdf(Result.pdf);