Is there a way to save changes to an excel spreadsheet through the excel interop (in this case I am adding a worksheet to it) without having it prompt the user if they want to overwrite the existing file with the changes. I do not want the user to even see the spreadsheet open in my application so having a message box popping up asking them if they want to overwrite the file seems very out of pl
有没有办法通过excel互操作保存对excel电子表格的修改(在这种情况下,我正在向其中添加工作表),而不会提示用户是否想要使用更改覆盖现有文件。 我不希望用户甚至在我的应用程序中看到电子表格打开,因此弹出一个消息框询问他们是否要覆盖文件,这看起来很不合适,可能会让用户感到困惑。 我正在使用workbook.SaveAs(fileloaction)方法。 这里是我为excel interop初始化COM引用对象的地方。 private Excel.Application
如何使用C#重命名文件? 看看System.IO.File.Move,将文件“移动”到一个新名称。 System.IO.File.Move("oldfilename", "newfilename"); System.IO.File.Move(oldNameFullPath, newNameFullPath); 你可以使用File.Move来完成它。
如何使用C#重命名文件? 看看System.IO.File.Move,将文件“移动”到一个新名称。 System.IO.File.Move("oldfilename", "newfilename"); System.IO.File.Move(oldNameFullPath, newNameFullPath); 你可以使用File.Move来完成它。
I'm looking for a class for creating CSV Excel files. Expected features: Extremely simple to use Escapes commas and quotes so excel handles them fine Exports date and datetimes in timezone-proof format Do you know any class capable of this? Slightly different version I wrote using reflection for my needs. I had to export a list of objects to csv. In case someone wants to use it
我正在寻找创建CSV Excel文件的课程。 预期功能: 使用非常简单 转义逗号和引号,以便excel处理它们 以时区格式导出日期和日期时间 你知道任何一类能够做到吗? 稍微不同的版本,我使用反射写我的需求。 我不得不将对象列表导出到csv。 如果有人想要使用它的未来。 public class CsvExport<T> where T: class { public List<T> Objects; public CsvExport(List<T> objects
This was working..and I moved the disposal code to the finally block, and now it fails every time. I have a test spreadsheet with 4 records, 6 columns long. Here is the code I'm using to bring it in. This is ASP .Net 3.5 on IIS 5 (my pc) and on IIS 6 (web server). It blows up on the line right before the catch: "values = (object[,])range.Value2;" with the following error: 11
这是工作..我把处理代码移动到finally块,现在每次都失败。 我有一个测试电子表格,包含4条记录,6列长。 这里是我使用的代码。这是IIS 5(我的电脑)和IIS 6(Web服务器)上的ASP .Net 3.5。 它就在catch之前的那条线上:“values =(object [,])range.Value2;” 出现以下错误: 11/2/2009 8:47:43 AM :: Not enough storage is available to complete this operation. (Exception from HRESULT: 0x8007000E (E_OUTOFMEM
我想扫描一个Excel表格,并用零代替社会安全号码的任何出现...我想使用Excel.Interop做到这一点,如果可能的话,但我现在对任何事情都是开放的......这里是我的一些代码...在过去的几个月里,我在桌子上敲着头... // Get range and convert it to a string variable Excel.Range _range =(Excel.Range)_excelApp.get_Range("A1:K1",Type.Missing); // convert the value of our cells in our range
我想扫描一个Excel表格,并用零代替社会安全号码的任何出现...我想使用Excel.Interop做到这一点,如果可能的话,但我现在对任何事情都是开放的......这里是我的一些代码...在过去的几个月里,我在桌子上敲着头... // Get range and convert it to a string variable Excel.Range _range =(Excel.Range)_excelApp.get_Range("A1:K1",Type.Missing); // convert the value of our cells in our range
Is there a free or open source library to read Excel files (.xls) directly from a C# program? It does not need to be too fancy, just to select a worksheet and read the data as strings. So far, I've been using Export to Unicode text function of Excel, and parsing the resulting (tab-delimited) file, but I'd like to eliminate the manual step. var fileName = string.Format("{0}\fileNameHer
是否有免费或开放源代码库直接从C#程序读取Excel文件(.xls)? 它不需要太花哨,只需选择一个工作表并将数据作为字符串读取即可。 到目前为止,我一直在使用导出到Excel的Unicode文本函数,并解析生成的(制表符分隔)文件,但我想消除手动步骤。 var fileName = string.Format("{0}\fileNameHere", Directory.GetCurrentDirectory()); var connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data sour
I have some code that opens a spreadsheet, reads some values, and then closes the sheet. I need to do this for multiple files. The problem I'm having is that the Excel application instance is not exiting, therefore when I run my process for several files, I end up with several excel.exe processes running. Any ideas how I get Excel to close? static void ParseFile(string file) {
我有一些代码可以打开电子表格,读取一些值,然后关闭表格。 我需要为多个文件执行此操作。 我遇到的问题是Excel应用程序实例没有退出,因此当我为多个文件运行我的进程时,最终会运行多个excel.exe进程。 任何想法如何让Excel关闭? static void ParseFile(string file) { try { System.Console.WriteLine("parsing:" + file); Excel.Application excel = new Excel.Applic
I'm trying to use the COM interop assembly to export some data to an Excel workbook for an ASP.NET web application. This works fine in development, since the server and the client are the same machine. However, when deployed, this is not the case. The deployed version does not throw an exception, but it also does not open Excel on the local machine (since ASP.NET is executed server-side, t
我正在尝试使用COM互操作程序集将某些数据导出到ASP.NET Web应用程序的Excel工作簿。 这在开发中工作正常,因为服务器和客户机是同一台机器。 但是,部署时情况并非如此。 部署的版本不会引发异常,但它也不会在本地计算机上打开Excel(因为ASP.NET在服务器端执行,这很明显)。 我如何着手在客户机上创建Excel应用程序? 您需要生成excel文件服务器端,然后使用适当的MIME类型将字节发送到客户端,以便客户端可以弄清楚
I'm writing a C# forms application to open an existing Excel workbook using the Excel Interop. Everything works fine. I can read and write fine. I do not save the workbook until the user close the C# application. The problem happens when my program is running and the user accidentally opens the same workbook with Excel. I get the error: Exception from HRESULT: 0x800401A8 at this line
我正在编写一个C#表单应用程序,以使用Excel Interop打开现有的Excel工作簿。 一切正常。 我可以读写很好。 在用户关闭C#应用程序之前,我不保存工作簿。 当我的程序正在运行并且用户意外地用Excel打开相同的工作簿时,会发生问题。 我收到错误: 来自HRESULT的异常:0x800401A8 在这条线上 范围excelRange = worksheet.UsedRange; 有没有办法锁定工作簿,并且不允许用户在我的程序运行时用Excel打开它? 谢谢
I have been using some functions for a while, and now I'm actually wondering, what is the difference between them. I know, that xlWorkbook.Close(0) closes the file, xlAppQuit(); quits the excel application, and Marshal.ReleaseComObject(xlWorkbook); cleans up - releases COM objects. But what does it mean in practice? I just can't imagine the differences. The first two make my excel p
我一直在使用一些函数,现在我真的在想,它们之间有什么区别。 我知道, xlWorkbook.Close(0)关闭文件xlAppQuit(); 退出Excel应用程序,并Marshal.ReleaseComObject(xlWorkbook); 清理 - 释放COM对象。 但是这在实践中意味着什么? 我无法想象这些差异。 前两个让我的任务管理器中的excel进程消失(那么如何关闭一个工作簿不同于退出,如果他们都杀死了excel进程?),最后一个不会。 你需要记住你调用的这些类是COM对象