我正在使用excel dna在excel文件中显示存储过程的结果,我想给excel表格的标题一个表格样式,但是我没有找到一种方法,我发现的例子不是我的情况,这是我的代码,它可能会解释更多:
public static object loadViewData(string date)
{
DateTime dt = DateTime.ParseExact(date, "dd/MM/yyyy", CultureInfo.InvariantCulture);
object[,] resultFromDB = getViewDataFromDB(dt);
object res= ArrayResizer.displayResultInExcelFile(resultFromDB);
return res;
}
getViewDataFromDB从sql Server返回数据,而displayResultInExcelFile将数据显示到excel文件中,这是它的代码:
public static object displayResultInExcelFile(object[,]array)
{
var caller = Excel(xlfCaller) as ExcelReference;
if (caller == null)
return array;
int rows = array.GetLength(0);
int columns = array.GetLength(1);
if (rows == 0 || columns == 0)
return array;
var rowLast = caller.RowFirst + rows - 1;
var columnLast = caller.ColumnFirst + columns - 1;
if (rowLast > ExcelDnaUtil.ExcelLimits.MaxRows - 1 ||
columnLast > ExcelDnaUtil.ExcelLimits.MaxColumns - 1)
{
return ExcelError.ExcelErrorValue;
}
ExcelAsyncUtil.QueueAsMacro(
delegate
{
var newTarget = new ExcelReference(caller.RowFirst + 1, rowLast + 1, caller.ColumnFirst, columnLast, caller.SheetId);
newTarget.SetValue(array);
} );
return array;
}
我可以将tableStyle添加到我的excel文件中吗?我想要类似的东西
TableStyle =“ TableStyleMedium9”;
谢谢
相关分类