以Windows应用程序格式表示每日/每周/每月报告

时间:2014-04-08 10:06:33

标签: c# sql excel

我有这个excel表,每天都需要修改我试图将它导出到Windows应用程序,并希望有数据库,但我不能理解how to create a table with this format in sql and how can i query on the table.我希望它显示为仪表板。对此有任何启发都会有所帮助。

这是我的代码:

private static Excel.Workbook MyBook = null; 
private static Excel.Application MyApp = null;
private static Excel.Worksheet MySheet = null;

MyApp = new Excel.Application();
MyApp.Visible = false;
MyBook = MyApp.Workbooks.Open(DB_PATH);
MySheet = (Excel.Worksheet)MyBook.Sheets[1]; // Explicit cast is not required here
lastRow = MySheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell).Row;

enter image description here

1 个答案:

答案 0 :(得分:0)

我不确定我是否理解你的问题。如果您在给定日期的某一天中遇到问题,请尝试此(sql server):

select datename(dw,getdate()) --Tuesday

您可以在数据库中使用datetime字段,并使用上面的查询来填充Excel工作表的“NAME”标题。