110,538
社区成员
发帖
与我相关
我的任务
分享
string filePath = System.Windows.Forms.Application.StartupPath + "\\Board.xls";
if (!File.Exists(filePath))
{
//******************************************************
Microsoft.Office.Interop.Excel.Application xls_exp = null; int rowindex = 1; int colindex = 0; //创建一个workbook,一个worksheet
Microsoft.Office.Interop.Excel._Workbook xls_book = null; Microsoft.Office.Interop.Excel._Worksheet xls_sheet = null;
try
{
string[] tt = new string[] { "客户简称", "客户姓名", "联系电话", "银行账号", "账户名称", "账户性质" };
xls_exp = new Microsoft.Office.Interop.Excel.ApplicationClass();
xls_book = xls_exp.Workbooks.Add(true);
xls_sheet = (Microsoft.Office.Interop.Excel._Worksheet)xls_book.ActiveSheet;
xls_sheet.Columns.NumberFormatLocal = "@";
xls_sheet.Name = "RelationerTable";
xls_sheet.Columns.se
foreach (string s in tt)
{
//这里怎么动态设置列名啊!!!!!!!!!!!!!
}
xls_exp.Visible = true;
object missing = System.Reflection.Missing.Value;
xls_exp.ActiveWorkbook.SaveAs(filePath, missing, missing, missing, missing, missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlShared, missing, missing, missing, missing, missing);
}
catch (Exception ex)
{
}
//******************************************************
}
else
{
System.Diagnostics.Process.Start(System.Windows.Forms.Application.StartupPath + "\\Board.xls");
}