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条回答

    报告相同问题?

    悬赏问题

    • ¥15 求差集那个函数有问题,有无佬可以解决
    • ¥15 【提问】基于Invest的水源涵养
    • ¥20 微信网友居然可以通过vx号找到我绑的手机号
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥65 汇编语言除法溢出问题