darknessomi / darknessomi/excellibrary

CellStyle

Open
#72 0 comments 0 reactions 0 assignees View on GitHub
auto-migrated Priority-Medium Type-Defect
Dominant language
C#
Stars
22
Forks
8
PR merge metrics
No merged PRs in 30d

Description

```
I set CellStyle with red color but output excel file with white cells.

public void SaveExcel(String filePath, DataSet dataset)
{
if (dataset.Tables.Count == 0)
throw new ArgumentException("DataSet needs to have at least one DataTable", "dataset");

Workbook workbook = new Workbook();
foreach (DataTable dt in dataset.Tables)
{
Worksheet worksheet = new Worksheet(dt.TableName);
for (int i = 0; i < dt.Columns.Count; i++)
{
// Add column header
worksheet.Cells[0, i] = new Cell(dt.Columns[i].ColumnName);
if (dt.Columns[i].Caption == TestColumn)
{
worksheet.Cells[0, i].Style = new CellStyle() { BackColor = System.Drawing.Color.Red };

}

// Populate row data
for (int j = 0; j < dt.Rows.Count; j++)
{
worksheet.Cells[j + 1, i] = new Cell(dt.Rows[j][i].ToString()) { Style = new CellStyle() { BackColor = System.Drawing.Color.Yellow } };
}
}
workbook.Worksheets.Add(worksheet);
}
workbook.Save(filePath);

}
```

Original issue reported on code.google.com by `marinazh...@gmail.com` on 10 Oct 2010 at 12:26

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the SaveExcel method and trace how CellStyle.BackColor is carried from Cell and Worksheet into Workbook.Save. Reproduce the example with red and yellow backgrounds, then inspect the generated Excel file to determine whether the saved output preserves those styles.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.