需要的功能是这样的。有一个excel模板,里面好多sheet页,我要把这个模板读出来,将DATASET中的数据逐行写进这个模板的第一个sheet页中,然后另存为另一个excel文件。哪位高人指点一下啊。另外的要求就是接照某一列的值不同,另存为不同的excel文件。原来我想把这个模板的列标题读出,再组合dataset导入到excel文件中,但是这个模板有很多sheet页,不能丢失。所以不知如何处理了。
解决方案 »
- 谷歌翻译API。。。。。。。。。。。。。。。。。。。。。。。。
- 求救,Web上文件上传,有没有人懂啊?问题解决马上结贴给分,在线等。
- 请教foreach循环问题,一个不规则数组{2,0,6,4,0,3,0,7}
- 这个问题真的有点难度 高手来!!!!!
- C#中如何将一个类中的静态变量赋值给另一个类的控件值
- 导出数据到excel的一些问题
- 关于对象序列化成流的问题,
- 急问DataGrid显示问题 (急)
- 未处理的“System.Data.ConstraintException”类型的异常出现在 system.data.dll 中。在线结..
- 请问一下FileStream流怎样转成Stream啊
- 配置文件如何读取一样的key?
- 求教高手!如何关闭框架中的一个页面,先谢谢了
2.create entries to temp.xls
2.rename temp.xlshttp://tech.163.com/06/0417/09/2ETC8KDJ0009159H.htmlif the datasoruce from sql,then you can using following :
http://support.microsoft.com/default.aspx?scid=kb;zh-cn;295646
myApp = New Excel.ApplicationClass
myApp.Visible = False
myApp.Workbooks.Open(_strNewExcelPath, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing)
myBook = myApp.Workbooks(1)
mySheets = CType(myBook.Worksheets, Excel.Worksheets)//这句出现错误,错误名:specified cast is not valid
mySheet = CType(mySheets(1), Excel.Worksheet)能帮我分析一下吗
Dim myBooks As Excel.Workbooks
Dim myBook As Excel.Workbook
Dim mySheet As Excel.Worksheet
Dim mySheets As Excel.Worksheets
Dim oMissing As Object
'复制文件
If File.Exists(_strNewExcelPath) Then
File.Delete(_strNewExcelPath)
End If File.Copy(_strExcelPath, _strNewExcelPath)
oMissing = System.Reflection.Missing.Value myApp = New Excel.ApplicationClass
myApp.Visible = False myApp.Workbooks.Open(_strNewExcelPath, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing)
myBooks = myApp.Workbooks
myBook = myBooks(1)
mySheets = myBook.Worksheets '我又调了一下,现在这句报和上句一样的错误,哪位高手帮忙分析一下啊,我查了好多都是这样写的啊。
mySheet = CType(mySheets(1), Excel.Worksheet)
改为 myBook = myApp.Workbooks.Open(_strNewExcelPath, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing)
mySheet = CType(myBook.Sheets(1), Excel.Worksheet)
这样就通过了。
另外想问大家一个问题。打开excel文件以后,如何将进程中的关于这个文件的进程杀死
private void KillProcess(string processName)
{
System.Diagnostics.Process myproc= new System.Diagnostics.Process();
//得到所有打开的进程
try{
foreach (Process thisproc in Process.GetProcessesByName(processName)) {
if(!thisproc.CloseMainWindow()){
thisproc.Kill();
}
}
}
catch(Exception Exc)
{
msg.Text+= "杀死" + processName + "失败!";
}
}