Excel Buffer OpenXML Change Text Font

marcos178marcos178 Member Posts: 11
edited 2013-02-15 in NAV Three Tier
Hi, I'm trying to change the TextFont (for example to Arial or Verdana) in the ExcelBuffer with the openXml, and im got this at this moment:
// Create new Font, cloned from existing Font
Font := WrkbookWriter.FirstWorksheet.DefaultCellDecorator.Font.CloneNode(TRUE);

// Create a new Font Color
FontColor := FontColor.Color;
FontColor.Rgb := FontHexValue.HexBinaryValue('0000EEEE');
Font.Color := FontColor;

// Create a new Font Size
FontSize := FontSize.FontSize;
FontSize.Val := FontSizeDoubleValue.DoubleValue(30);
Font.FontSize := FontSize;

// Create a new Font Text
FontName := FontName.FontName;
//FontNameStringValue := FontNameStringValue.StringValue('Arial');
FontName.Val := FontNameStringValue.FromString('Arial');
Font.FontName := FontName;


// Get the collection of Fonts that already exists
Fonts := WrkbookWriter.Workbook.WorkbookPart.WorkbookStylesPart.Stylesheet.Fonts;

// Add the new font to the collection of fonts and increate the number of fonts with one.
IF OpenXmlHelper.AppendChild(Fonts,Font) THEN
  Fonts.Count.Value := Fonts.Count.Value + 1;

// Add the Font to a decorator
Decorator := WrkbookWriter.FirstWorksheet.DefaultCellDecorator;
Decorator.Font := Font;


But I don't know how this doesnt work, can anyone tell me where is the problem? I saw a lot of pages with examples in C# but the all of i tried doesnt worked :S

Comments

  • marcos178marcos178 Member Posts: 11
    Any help? :P
  • beranberan Member, Microsoft Employee Posts: 80
    You cannot update the DefaultCellDecorator - it is a copy each time...

    I am home with sick kids today but I will look up the AL code Monday to see, what you can do.
    Eric Beran
    Software Design Engineer II
    Dynamics NAV Office 365
    Microsoft

    This posting is provided "AS IS" with no warranties, and confers no rights.
Sign In or Register to comment.