【发布时间】:2015-03-06 21:07:07
【问题描述】:
我正在使用 CloseXML 将一些数据从访问权限导出到 excel,我正在尝试对某些日期进行条件格式设置,但我收到了 NULL EXCEPTION REFERENCE ERROR。这是我所拥有的。
using (OleDbConnection connection = new OleDbConnection(conecctionstring))
{
string selectquery = "querystring";
using (OleDbDataAdapter selectCommand = new OleDbDataAdapter(selectquery, connection))
{
DtSet1 = new DataSet();
selectCommand.Fill(DtSet2, "Table1");
var wb = new XLWorkbook();
var saveFileDialog = new SaveFileDialog
{
Filter = "Excel files|*.xlsx",
Title = "Save an Excel File"
};
wb.Worksheets.Add(DtSet1);
wb.Range("C:C").AddConditionalFormat().WhenEqualOrGreaterThan(DateTime.Now.ToOADate()).Fill.SetBackgroundColor(XLColor.Red);
saveFileDialog.ShowDialog();
if (!String.IsNullOrWhiteSpace(saveFileDialog.FileName))
wb.SaveAs(saveFileDialog.FileName);
}
}
我正在使用 C#、OpenXML 和 Access DB 任何帮助表示赞赏。
【问题讨论】:
-
哪一行产生了错误?
-
"wb.Range("C:C").AddConditionalFormat().WhenEqualOrGreaterThan(DateTime.Now.ToOADate()).Fill.SetBackgroundColor(XLColor.Red)"
标签: c# conditional-formatting closedxml