Posts

Showing posts with the label OpenXML

Donate

How To Add Cell Borders Or Grid Lines To Filled Cells In Excel Using ClosedXML

Image
Hello, When dealing with filled cells or columns of an Excel workshet via ClosedXML, you may notice that after you produced the Excel file(s), the filled columns or cells don't have borders. This assume that your report does not apply borders to the used cells or columns such as the image below. To apply borders to certain columns within a range or not, you need to set both the Outside and Inside borders with Thin borderstyle. And then apply your preferred color to the top, bottom, left and right borders. row++; xlWSheet.Range( 1 , 1 , row, 7 ).Style.Border.SetOutsideBorder(XLBorderStyleValues.Thin) .Border.SetInsideBorder(XLBorderStyleValues.Thin) .Border.SetTopBorderColor(XLColor.LightGray) .Border.SetBottomBorderColor(XLColor.LightGray) .Border.SetLeftBorderColor(XLColor.LightGray) .Border.SetRightBorderColor(XLColor.LightGray); Filled columns or cells with borders. Cheers!

Generate Page Numbers Of Word Document Using OpenXML

Hello, I've been working on OpenXML framework specifically for generating reports on a Word Document. One of the task of the project is to add page numbers to a document with the format of "Page 1 of 72". After doing some researches on stackoverflow and google, I found a few links with functions on how to add page numbers but not in the format as specified for my requirement. In case you need to add page numbers to a word document specifically in the footer area, see function below. private Footer GeneratePageNumbers ( string FooterText) { var element = new Footer ( new Paragraph ( new ParagraphProperties ( new ParagraphStyleId () { Val = "Footer" }, new Justification () { Val = JustificationValues.Center }), new Run ( new Text () { Text = FooterText, Space = SpaceProcessingModeValues.Preserve }), new Run ( new SimpleField () { Instruction = "Page" }), new Run ( new Text () { Te

Donate