Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to make a excel sheet right to left with closedXML

I am using closedXML to generate a XML file(in arabic) and i need this file to be in right to left layout how can it do this in closedXML.

XLWorkbook wb = new XLWorkbook();
var ws = wb.Worksheets.add("Sheet1");
ws.Cell(1,1).Value = "مرحبا";
ws.Style.Alignment.ReadingOrder = XLAlignmentReadingOrderValues.RightToLeft;
like image 959
Asanka Madushan Avatar asked Jun 28 '16 06:06

Asanka Madushan


People also ask

Does ClosedXML support XLS?

ClosedXML is a . NET library for reading, manipulating and writing Excel 2007+ (. xlsx, . xlsm) files.

What is the difference between OpenXML and ClosedXML?

ClosedXML is an open source library created based on OpenXmlSdk. It's more user friendly. ClosedXML is a . NET library for reading, manipulating and writing Excel 2007+ (.

Is ClosedXML safe?

ClosedXML is not thread-safe. There is no guarantee that parallel operations will work. The underlying OpenXML library is also not thread-safe. If you get an exception The type initializer for 'Gdip' threw an exception.


1 Answers

Both the XLWorkbook and XLWorksheet objects have a RightToLeft property. You can either set it to true for the entire workbook or for each individual sheet.

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");
like image 60
Paul-Jan Avatar answered Oct 13 '22 06:10

Paul-Jan