sdwhcool 2014-06-04 13:58
浏览 1193

请教C#,Form窗口的一个Button,调用Excel导出表格时出错

一个调用Excel导出表的操作,出错。请熟悉excel调用的高手指教。

相关代码:
private void button1_Click(object sender, EventArgs e)
{
saveFileDialog1.AddExtension = true;//对话框自动在文件名中添加扩展名
saveFileDialog1.FileName = name+"与"+name1+"担保信息";//设置对话框初始目录
saveFileDialog1.Filter = "excel files(*.xls)|*.xls";
saveFileDialog1.FilterIndex = 0;
saveFileDialog1.ShowDialog();//弹出对话框
// MessageBox.Show(filename);
if (filename != null)
ExcelExport.CreateExcel(dt, filename);
}

在电脑A上正常运行。在电脑B上出现如下提示。其中,电脑A未安装WPS。电脑B安装WPS后又安装了微软Office2003,xls文件默认仍以Excel打开。

以下是错误提示:
System.IO.FileNotFoundException: Could not load file or assembly 'office, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. 系统找不到指定的文件。
File name: 'office, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
at DBQ.ExcelExport.CreateExcel(DataTable dt, String fileName)
at DBQ.district_find_inf.button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value HKLM\Software\Microsoft\Fusion!EnableLog to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
    • ¥30 python代码,帮调试
    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿
    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥100 Jenkins自动化部署—悬赏100元