Hello,
I try to use Excel Buffer to create an Excel file with format modifications to apply. More specially, to have cells with borders. After many tries and searches, i have modified the function GetCellDecorator and add this lines at the end :
Border := XlWrkShtWriter.DefaultCellDecorator.Border.CloneNode(TRUE);
BorderColor := BorderColor.Color;
BorderColor.Auto:=BooValue.FromBoolean(TRUE);
Border.LeftBorder.Style:=BorderStyle.Thin;
Border.LeftBorder.Color:=BorderColor;
Decorator.Border:=Border;
The variables created are :
Border DocumentFormat.OpenXml.Spreadsheet.Border
BorderColor DocumentFormat.OpenXml.Spreadsheet.Color
BorderStyle DocumentFormat.OpenXml.Spreadsheet.BorderStyleValues
BooValue DocumentFormat.OpenXml.BooleanValue
But, i have this error raising : DocumentFormat.OpenXML.Spreadsheet.LeftBorder.set_style failed with this message. The type of one or more arguments does not match the method's parameter type.
Does someone know what i do wrong?
Thanks
0
Comments
The only real limitation stopping me from using the now native openxml for excel output is not being able to do borders...
Bruce Anderson
Create an excel with OpenXml is a very complex task.
We re-implemented the excel buffer with closedxml (https://closedxml.codeplex.com/) and managing borders, cell merge, etc is more easy.
Matteo
I’ve found a solution. I was thinking about how Excel Buffer do “underline”, in fact is a BottomBorder… the solution was copying the style of BottomBorder to other border sides:
Local Variable:
Function that replace Excel Buffer GetCellDecorator:
I’ve spend a lot of time with this problem… I hope help someone with this.
Thank you for your solution
However, for me, my XlWrkShtWriter.DefaultUnderlinedCellDecorator created a top, left and right border but no bottom border which I thought was a bit weird
However, the princple was the same as I could just declare a bottom border by using the border objects top border (or left or right), so it all worked out for me in the end
Thanks