一个关于操作Excel的问题。。 我用程序新建了一个excel表,往里面添加了一些数据。此时我又想通过程序查看这个Excel表。这个该怎么实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 System.Diagnostics.Process.Start(fileName); 你理解错我的意思了,我是说我的程序在添加数据时已经在使用excel表,我再点击一个BUTTON去查看这个EXCEL表肯定是不行的。。所以这两个操作间我该怎么做才能执行第二个操作 不大明白LZ的意思.. 把Excel 当数据库用? - -|string strConn = "Provider=Microsoft.Jet.OleDb.4.0;" + "data source=" + strFileName + ";Extended Properties='Excel 8.0; HDR=YES; IMEX=1'"; string strExcel = string.Format("select * from [{0}$]", "Sheet1"); DataSet ds = new DataSet(); string editType = "0"; bool IsError = false; bool Check = true; String tips = ""; ArrayList Alist = new ArrayList(); String sSRRQ = sqldata.ExecuteSQLReturn("select convert(varchar(10),getdate(),102)"); String sSRSJ = sqldata.ExecuteSQLReturn("select Convert(varchar(10),getdate(),108)"); using (OleDbConnection conn = new OleDbConnection(strConn)) { conn.Open(); OleDbDataAdapter adapter = new OleDbDataAdapter(strExcel, strConn); adapter.Fill(ds, "Sheet1"); conn.Close(); } 查看修改前的还是修改之后的excel 那杀进程呢!添加完成后杀掉这个excel的进程!然后再做其他的操作!! System.Windows.Forms.Application.DoEvents(); object Nothing = System.Reflection.Missing.Value; object filename = FilePath + "\\" + docName; object docname = SavePath + "\\" + docName; //new一个word类对象 Microsoft.Office.Interop.Word.Application WordApp = new Microsoft.Office.Interop.Word.ApplicationClass(); //打开指定路径的word文档 Microsoft.Office.Interop.Word.Document WordDoc = WordApp.Documents.Open(ref filename, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);用类似打开word的方法打开excel不行吗 C# 事件访问器 VC#中删除图像资源后菜单和工具栏按钮都消失了 如何限制进程的下载速度 当按最大化时.最大化窗口时如何使里面的控件根据比例同样放大? 如何在WPF中对3D物体写相应的事件? 连本地sql数据库时为啥总出现出现远程连接错误?急!在线等!!!!! 文件监视中监视的文件如果更改了文件,它的Changed事件触发两次? 求助,谢谢大家了 IM项目基本方案 请高手解决一个xml修改问题,我都急哭了 选项卡问题,谢谢大家 如何系统的学好C#,然后找到个好工作
string strExcel = string.Format("select * from [{0}$]", "Sheet1");
DataSet ds = new DataSet(); string editType = "0";
bool IsError = false;
bool Check = true;
String tips = "";
ArrayList Alist = new ArrayList();
String sSRRQ = sqldata.ExecuteSQLReturn("select convert(varchar(10),getdate(),102)");
String sSRSJ = sqldata.ExecuteSQLReturn("select Convert(varchar(10),getdate(),108)"); using (OleDbConnection conn = new OleDbConnection(strConn))
{
conn.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter(strExcel, strConn);
adapter.Fill(ds, "Sheet1");
conn.Close();
}
然后再做其他的操作!!
object Nothing = System.Reflection.Missing.Value;
object filename = FilePath + "\\" + docName;
object docname = SavePath + "\\" + docName;
//new一个word类对象
Microsoft.Office.Interop.Word.Application WordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
//打开指定路径的word文档
Microsoft.Office.Interop.Word.Document WordDoc = WordApp.Documents.Open(ref filename, ref Nothing, ref Nothing,
ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing,
ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
用类似打开word的方法打开excel不行吗