Hello,
Thanks for your interested in our products.
Sorry that our Spire.DataExport doesn't support to format the specific value at present, but our other products can achieve it.
You could please use Spire.Xls to get Excel.
- Code: Select all
static void GetExcel()
{
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
//the datatable is yours
sheet.InsertDataTable(datable, true, 1, 1);
foreach (CellRange cell in sheet.Cells)
{
if (cell.Value == "negative")
{
cell.Style.Font.Color = Color.Red;
}
if (cell.Value == "positive")
{
cell.Style.Font.Color = Color.Green;
}
}
workbook.SaveToFile("sample.xlsx", ExcelVersion.Version2007);
}
You could please use Spire.Doc to get HTML and PDF you want.
- Code: Select all
Document document = new Document();
Section section = document.AddSection();
Table table= section.AddTable(true);
table.TableFormat.Borders.BorderType = BorderStyle.Single;
//the datatable is yours
table.ResetCells(datatable.Rows.Count, datatable.Columns.Count);
string value=null;
TableCell cell=null;
TextRange range = null;
for (int i = 0; i < datatable.Rows.Count; i++)
{
for (int j = 0; j < datatable.Columns.Count; j++)
{
value= datatable.Rows[i][j].ToString();
cell = table.Rows[i].Cells[j];
cell.CellFormat.Borders.LineWidth = 1;
range= cell.AddParagraph().AppendText(value);
if (value == "negative")
{
range.CharacterFormat.TextColor = Color.Red;
}
if (value == "positive")
{
range.CharacterFormat.TextColor = Color.Green;
}
}
}
//Get Html
document.SaveToFile("sample.html",FileFormat.Html);
//Get PDF
//document.SaveToFile("sample.pdf",FileFormat.PDF);
Welcome to download and test Spire.Xls and Spire.Doc.
Downloading link of Spire.Xls:
http://www.e-iceblue.com/Download/downl ... t-now.htmlDownloading link of Spire.Doc:
http://www.e-iceblue.com/Download/downl ... t-now.htmlPlease feel free to write to us if you have further problems.
Best regards,
Amy
E-iceblue support team