Quantcast
Channel: General Office Development forum
Viewing all articles
Browse latest Browse all 2257

Add column headers to worksheet

$
0
0

Hi,

I am able to write the values to excel rows using the below code.

              foreach (var item in ExcelData)
                {
                    DocumentFormat.OpenXml.Spreadsheet.Row newRow = new DocumentFormat.OpenXml.Spreadsheet.Row();

                    DocumentFormat.OpenXml.Spreadsheet.Cell cellComponent = new DocumentFormat.OpenXml.Spreadsheet.Cell();
                    cellComponent.DataType = DocumentFormat.OpenXml.Spreadsheet.CellValues.String;
                    cellComponent.CellValue = new DocumentFormat.OpenXml.Spreadsheet.CellValue(item.ComponentName);
                    newRow.AppendChild(cellComponent);

                    DocumentFormat.OpenXml.Spreadsheet.Cell cellProperty = new DocumentFormat.OpenXml.Spreadsheet.Cell();
                    cellProperty.DataType = DocumentFormat.OpenXml.Spreadsheet.CellValues.String;
                    cellProperty.CellValue = new DocumentFormat.OpenXml.Spreadsheet.CellValue(item.Property);
                    newRow.AppendChild(cellProperty);

                    DocumentFormat.OpenXml.Spreadsheet.Cell cellExpression = new DocumentFormat.OpenXml.Spreadsheet.Cell();
                    cellExpression.DataType = DocumentFormat.OpenXml.Spreadsheet.CellValues.String;
                    cellExpression.CellValue = new DocumentFormat.OpenXml.Spreadsheet.CellValue(item.Expressions);
                    newRow.AppendChild(cellExpression);

                    sheetData.Append(newRow);
                }

 Now how can I add three column headers in this code with Bold Font?



Viewing all articles
Browse latest Browse all 2257

Trending Articles



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