Ich habe dieses Blatt in Excel Export benannt und ich möchte, dass seine Kopfzeile grau sein. Hier ist der Code:Excel-Zellen Färbung
protected void btnExcel_OnClick(object sender, EventArgs e)
{
var ex = new Aspose.Cells.Workbook();
ex.Worksheets.Clear();
Aspose.Cells.Worksheet ws = ex.Worksheets.Add("Export");
ws.Cells.ImportTable(Export.GetExportList(GetWhereClause(), ConfigurationManager.AppSettings();
ws.Cells[0, 0].PutValue("A");
ws.Cells[0, 1].PutValue("B");
ws.Cells[0, 2].PutValue("C");
ws.Cells[0, 3].PutValue("D");
ws.Cells[0, 4].PutValue("E");
var style = ws.Cells.Rows[0].Style;
style.Font.IsBold = true;
ws.Cells.Rows[0].ApplyStyle(style, new StyleFlag { FontBold = true });
ex.Save(string.Format("Export_{0}.xlsx", DateTime.Now.ToString("yyyyMMdd_HHmmss")), FileFormatType.Excel2007Xlsx, SaveType.OpenInExcel, Response);
}
ich auch auf die Schaltfläche Code enthalten. Ich habe so etwas wie dies versucht:
style.BackgroundColor = Color.DarkGrey;
oder
ws.Cells[0, 0].Style.BackgroundColor = Color.DarkGrey;
Und ich weiß nicht, die method.Nothing Werke .Interior
haben. Was kann ich tun?
Was meinst du mit "nichts funktioniert"? Was genau funktioniert nicht? – haindl
haben Sie versucht, den Zellen den Stil individuell anzupassen? wie ws.Cells [0,0] .SetStyle (style); –
@haindl die Zeilen Code, die ich oben versucht habe. Die Farbe erscheint überhaupt nicht. –