LOCAL WriteCellValue(ExcelBuffer : Record "Excel Buffer") WITH ExcelBuffer DO BEGIN GetCellDecorator(Bold,Italic,Underline,Decorator); CASE "Cell Type" OF "Cell Type"::Number: XlWrkShtWriter.SetCellValueNumber("Row No.",xlColID,"Cell Value as Text",NumberFormat,Decorator); "Cell Type"::Text: XlWrkShtWriter.SetCellValueText("Row No.",xlColID,"Cell Value as Text",Decorator); "Cell Type"::Date: XlWrkShtWriter.SetCellValueDate("Row No.",xlColID,"Cell Value as Text",NumberFormat,Decorator); "Cell Type"::Time: XlWrkShtWriter.SetCellValueTime("Row No.",xlColID,"Cell Value as Text",NumberFormat,Decorator); ELSE ERROR(Text039) END; // Cust1.00 Start IF "Column Width" > 0 THEN BEGIN myOpenXml.SetColumnWidth("Column No.", "Column Width", XlWrkShtWriter.Worksheet); END; // Cust1.00 End END;
public static void SetColumnWidth(uint columnIndex, decimal width, Worksheet openXmlWorksheet) { var columns = openXmlWorksheet.GetFirstChild<Columns>(); var column = columns.ChildElements.FirstOrDefault(t => (t is Column) && (t as Column).Min <= columnIndex && (t as Column).Max <= columnIndex) as Column; if (column == null) { column = new Column() { Min = columnIndex, Max = columnIndex }; columns.Append(column); } column.CustomWidth = true; column.Width = Convert.ToDouble(width); }
Comments
You use "Column No." the example uses xlColID
/Juha
http://www.epimatic.com