Quantcast
Channel: Open XML Format SDK forum
Viewing all articles
Browse latest Browse all 1288

How to format Excel cells programmatically using C#?

$
0
0

1. How to format the font to BOLD.  In the cold below, I used f.FontId = 1, but it didn't work.

2. How to add color to the font?

3. How to set the column width with auto max?

4. With f.NumberFormatId = 4, the output is #,##0.00 which is correct. But how can I get 4 decimals, like #,##0.0000?

var excelStyleSheet = new ExcelStylesheet();

                excelStyleSheet.AddCellFormat("Numeric", (f) =>
                {
                    f.NumberFormatId = 4; // #,##0.00
                    f.Alignment = new Alignment() { Horizontal = HorizontalAlignmentValues.Right, Vertical = VerticalAlignmentValues.Center };
                    f.ApplyNumberFormat = BooleanValue.FromBoolean(true);
                });

                excelStyleSheet.AddCellFormat("Header", (f) =>
                {
                    f.FontId = 1;
                    f.Alignment = new Alignment() { Horizontal = HorizontalAlignmentValues.Center, Vertical = VerticalAlignmentValues.Center };
                    f.ApplyFont = BooleanValue.FromBoolean(true);
                });



Viewing all articles
Browse latest Browse all 1288

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>