Name DataType Subtype Length CustomFontPool DotNet System.Collections.Generic.Dictionary`2.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
GetCustomCellDecorator(IsBold : Boolean;IsItalic : Boolean;IsUnderlined : Boolean;Color : Integer;FontSize : Integer;VAR Decorator : DotNet "Microsoft.Dynamics.Nav.OpenXml.Spreadsheet.CellDecorator") GetCellDecorator(IsBold, IsItalic, IsUnderlined, BaseDecorator); Decorator := BaseDecorator; // Handle Extension IF (Color <> 0) OR (FontSize <> 0) THEN BEGIN FontIndex := STRSUBSTNO('%1|%2|%3|%4|%5',IsBold, IsItalic, IsUnderlined, Color, FontSize); CustomFont := BaseDecorator.Font.CloneNode(TRUE); // Color IF Color <> 0 THEN BEGIN CustomColor := CustomColor.Color; CASE Color OF 3 : CustomColor.Rgb := HexColor.HexBinaryValue('00FF0000'); // Red 5 : CustomColor.Rgb := HexColor.HexBinaryValue('001B1BC3'); // Blue 10 : CustomColor.Rgb := HexColor.HexBinaryValue('0022B400'); // Green END; CustomFont.Color := CustomColor; END; // Font Size IF FontSize <> 0 THEN BEGIN CustomFontSize := CustomFontSize.FontSize; CustomFontSize.Val := FontSizeValue.DoubleValue(FontSize); CustomFont.FontSize := CustomFontSize; END; Fonts := XlWrkBkWriter.Workbook.WorkbookPart.WorkbookStylesPart.Stylesheet.Fonts; AddFontToCollection(Fonts, CustomFont, FontIndex); Decorator.Font := CustomFont; END;
Name DataType Subtype Length CustomFont DotNet DocumentFormat.OpenXml.Spreadsheet.Font.'DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' CustomFontSize DotNet DocumentFormat.OpenXml.Spreadsheet.FontSize.'DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' CustomColor DotNet DocumentFormat.OpenXml.Spreadsheet.Color.'DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' HexColor DotNet DocumentFormat.OpenXml.HexBinaryValue.'DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' BaseDecorator DotNet Microsoft.Dynamics.Nav.OpenXml.Spreadsheet.CellDecorator.'Microsoft.Dynamics.Nav.OpenXml, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Fonts DotNet DocumentFormat.OpenXml.Spreadsheet.Fonts.'DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' FontSizeValue DotNet DocumentFormat.OpenXml.DoubleValue.'DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' FontIndex Text
AddFontToCollection(_Fonts : DotNet "DocumentFormat.OpenXml.Spreadsheet.Fonts";VAR _CustomFont : DotNet "DocumentFormat.OpenXml.OpenXmlElement";_Index : Text) : Boolean IF ISNULL(CustomFontPool) THEN CustomFontPool := CustomFontPool.Dictionary(); IF CustomFontPool.TryGetValue(_Index, TempFont) THEN BEGIN // Already in Collection _CustomFont := TempFont; EXIT; END ELSE BEGIN // OpenXML Element Array Arr := Arr.CreateInstance(GETDOTNETTYPE(_CustomFont),1); Arr.SetValue(_CustomFont,0); _Fonts.Append(Arr); _Fonts.Count.Value := _Fonts.Count.Value + 1; CustomFontPool.Add(_Index, _CustomFont); END;
Name DataType Subtype Length i Integer Arr DotNet System.Array.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' TempFont DotNet DocumentFormat.OpenXml.OpenXmlElement.'DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
//GetCellDecorator(Bold,Italic,Underline,Decorator); GetCustomCellDecorator(Bold,Italic,Underline,Color,"Font Size",Decorator);
Comments
I followed your example - and it is working great
I have added changing font to it - and it is still working as expected.
Then I wanted to add Fill Color for each cell.
Setting the fill colour was similar to other alterations - but I hit the wall when trying to set FillType to 'Solid':
I think I know how this supposed to look like... but I just cannot figure out how I supposed to use / create PatternType object.
Starting from the top:
Decorator
---> Fill ...............................................(DocumentFormat.OpenXml.Spreadsheet.Fill )
> PatternFill.............................(DocumentFormat.OpenXml.Spreadsheet.PatternFill)
> ForegroundColour.......(DocumentFormat.OpenXml.Spreadsheet.ForegroundColor)
> PatternType................(DocumentFormat.OpenXml.EnumValue(Of PatternValues))
If I comment out line {1111} I receive an error:
If I leave it there is another:
Looks like constructor does not work... or I don't know how to use it here.
PatternType property supposed to be filled with object of type: DocumentFormat.OpenXml.EnumValue(Of PatternValues) where PatternValues is enumeration of values.
In My example variable CustomPatternType is DocumentFormat.OpenXml.Spreadsheet.PatternValues and I can see all possible values - including 'Solid' which I want to use.
Variable PatternListValue is DocumentFormat.OpenXml.EnumValue`1 which supposed to match a type of PatternType property which I am trying to set.
](*,) ](*,) ](*,)
Any suggestions?... I probably miss some silly notation which will make everything work as expected.... :oops:
Bruno
http://blogs.ittoolbox.com/erp/smb
But it didn't work in 100%... in fact it works very strange...
First cell having a fill - is always incorrect... and any next if the fill type stays the same.
But after changing fill type each next cell is working correctly.
I ended up with setting some crazy fill type for first cell - where I do not care how it looks like and then - for any other cells fill is correct.
A bit crazy... I know
I'm trying to make this work on nav 2013 but I'm facing an error stating that "... : A dotnet variable has not been instantiated. Attempting to call Microsoft.dynamics.nav.openxmlspreadsheet.worksheetwriter.defaultcelldecorator in table excel buffer: GetCellDecorator".
After some debugging I have detected that the error raises in the call to the function GetCellDecorator from the new function GetCustomCellDecorator.
Any idea of what may be happening? I have went over every step but I can't find the bug.
Thanks in advance.
Any hints how to implement vertical/horizontal align?
](*,) As Makina (Apr 22, 2014), I'm trying to make this work on nav 2013 but I'm facing an error stating that "... : A dotnet variable has not been instantiated. Attempting to call Microsoft.dynamics.nav.openxmlspreadsheet.worksheetwriter.defaultcelldecorator in table excel buffer: GetCellDecorator".
[-o< Can someone who has implemented this post explain what happens with the function GetCellDecorator called from the new function GetCustomCellDecorator ?
:idea: Where and how should it be instantiated ?
:thumbsup: I hope that someone can post a fob with just the new working T00370 functions ?
Kind regards,
L
:?: ps : is it still the same in NAV2015 ?
I fixed it defining functions GetCustomCellDecorator and AddFontToCollection as local (NAV2013R2).
Now everything is working fine.
https://saurav-nav.blogspot.in/2016/03/nav-2013-r2-export-to-excel-with-font.html
Thanks & Regards,
Saurav Dhyani
Do you Know this About NAV?
Connect - Twitter | Facebook | Google + | YouTube
Follow - Blog | Facebook Page | Google + Page
did you find solution?
All this works.
Please how to add comments to a cellule
Thx