是否可以使用closedXML从右到左制作Excel工作表

时间:2016-06-28 06:21:38

标签: c# excel closedxml

我正在使用closedXML生成一个XML文件(阿拉伯语),我需要这个文件在从右到左的布局中如何在closedXML中执行此操作。

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

1 个答案:

答案 0 :(得分:4)

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");