Hi All,
Currently I am working in a vb.net web application where I need to export data to excel, I am using DocumentFormat.OpenXML package to do the same.
In that I am creating a stylesheet to format the excel, but I am facing an issue with the currency format where I need it exactly as$331.87
The below method only I am using, except the numbering format rest all works fine. Please help me to resolve it.
Private Function GenerateStyleSheetNew() As Stylesheet Return New Stylesheet(New DocumentFormat.OpenXml.Spreadsheet.Fonts(New Font(New FontSize() With {.Val = 10}, New Color() With {.Rgb = New HexBinaryValue() With {.Value = "000000"}}, New FontName() With {.Val = "Arial"}), New Font(New Bold(), New FontSize() With {.Val = 10}, New Color() With {.Rgb = New HexBinaryValue() With {.Value = "000000"}}, New FontName() With {.Val = "Arial"}), New Font(New Italic(), New FontSize() With {.Val = 10}, New Color() With {.Rgb = New HexBinaryValue() With {.Value = "000000"}}, New FontName() With {.Val = "Arial"}), New Font(New FontSize() With {.Val = 16}, New Color() With {.Rgb = New HexBinaryValue() With {.Value = "000000"}}, New FontName() With {.Val = "Times New Roman"})), New Fills(New DocumentFormat.OpenXml.Spreadsheet.Fill(New DocumentFormat.OpenXml.Spreadsheet.PatternFill() With {.PatternType = PatternValues.None}), New DocumentFormat.OpenXml.Spreadsheet.Fill(New DocumentFormat.OpenXml.Spreadsheet.PatternFill() With {.PatternType = PatternValues.Gray125}), New DocumentFormat.OpenXml.Spreadsheet.Fill(New DocumentFormat.OpenXml.Spreadsheet.PatternFill(New DocumentFormat.OpenXml.Spreadsheet.ForegroundColor() With {.Rgb = New HexBinaryValue() With {.Value = "FFFFE0"}}) With {.PatternType = PatternValues.Solid}), New DocumentFormat.OpenXml.Spreadsheet.Fill(New DocumentFormat.OpenXml.Spreadsheet.PatternFill(New DocumentFormat.OpenXml.Spreadsheet.ForegroundColor() With {.Rgb = New HexBinaryValue() With {.Value = "CCFFCC"}}) With {.PatternType = PatternValues.Solid})), New Borders(New Border(New DocumentFormat.OpenXml.Spreadsheet.LeftBorder(), New DocumentFormat.OpenXml.Spreadsheet.RightBorder(), New DocumentFormat.OpenXml.Spreadsheet.TopBorder(), New DocumentFormat.OpenXml.Spreadsheet.BottomBorder(), New DiagonalBorder()), New Border(New DocumentFormat.OpenXml.Spreadsheet.LeftBorder(New Color() With {.Auto = True}) With {.Style = BorderStyleValues.Thin}, New DocumentFormat.OpenXml.Spreadsheet.RightBorder(New Color() With {.Auto = True}) With {.Style = BorderStyleValues.Thin}, New DocumentFormat.OpenXml.Spreadsheet.TopBorder(New Color() With {.Auto = True}) With {.Style = BorderStyleValues.Thin}, New DocumentFormat.OpenXml.Spreadsheet.BottomBorder(New Color() With {.Auto = True}) With {.Style = BorderStyleValues.Thin}, New DiagonalBorder())), New DocumentFormat.OpenXml.Spreadsheet.NumberingFormats(New DocumentFormat.OpenXml.Spreadsheet.NumberingFormat() With {.NumberFormatId = 1, .FormatCode = "#,##0.00"}), New CellFormats(New CellFormat() With {.FontId = 0, .FillId = 0, .BorderId = 0}, New CellFormat() With {.FontId = 1, .FillId = 0, .BorderId = 0, .ApplyFont = True}, New CellFormat() With {.FontId = 2, .FillId = 0, .BorderId = 0, .ApplyFont = True}, New CellFormat() With {.FontId = 3, .FillId = 2, .BorderId = 1, .ApplyFont = True}, New CellFormat(New Alignment() With {.Horizontal = HorizontalAlignmentValues.Center, .Vertical = VerticalAlignmentValues.Bottom}) With {.FontId = 1, .FillId = 3, .BorderId = 1, .ApplyFill = True, .ApplyAlignment = True}, New CellFormat(New Alignment() With {.Vertical = VerticalAlignmentValues.Bottom}) With {.FontId = 0, .FillId = 2, .BorderId = 1, .ApplyAlignment = True}, New CellFormat(New Alignment() With {.Vertical = VerticalAlignmentValues.Bottom}) With {.FontId = 0, .FillId = 0, .BorderId = 1, .ApplyAlignment = True}, New CellFormat(New Alignment() With {.Horizontal = HorizontalAlignmentValues.Center, .Vertical = VerticalAlignmentValues.Center}) With {.FontId = 0, .FillId = 0, .BorderId = 0, .ApplyAlignment = True, .NumberFormatId = 166, .ApplyNumberFormat = True}, New CellFormat() With {.FontId = 0, .FillId = 0, .BorderId = 0, .NumberFormatId = 166, .ApplyNumberFormat = True}, New CellFormat() With {.FontId = 0, .FillId = 0, .BorderId = 1, .ApplyBorder = True})) End Function