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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)