是否可以用closedXML从右向左制作excel表格?

本文关键字:excel 表格 closedXML 是否 | 更新日期: 2023-09-27 17:51:23

我使用closedXML生成一个XML文件(在阿拉伯语),我需要这个文件是在右到左的布局如何在closedXML中做到这一点。

XLWorkbook wb = new XLWorkbook();
var ws = wb.Worksheets.add("Sheet1");
ws.Cell(1,1).Value = "مرحبا";
ws.Style.Alignment.ReadingOrder = XLAlignmentReadingOrderValues.RightToLeft;

是否可以用closedXML从右向左制作excel表格?

XLWorkbook和XLWorksheet对象都有一个RightToLeft属性。您可以将其设置为整个工作簿或每个单独的工作表的true

var workbook = new XLWorkbook {RightToLeft = true}; // <-- Workbook default RTL
var worksheet = workbook.Worksheets.Add("Sample Sheet");
worksheet.Cell("A1").Value = "Hello World!";
// worksheet.RightToLeft = true;  <-- To set RightToLeft for individual worksheets
workbook.SaveAs("HelloWorld.xlsx");