excel-interop

Exporting Several XtraGrid Controls to a Single Excel File

空扰寡人 提交于 2019-11-29 12:36:25
I've got several XtraGrid Controls each one containing different information, I get some information about the way in which you can export a XtraGrid to an Excel file in the following direction http://www.devexpress.com/Support/Center/p/Q362120.aspx Now Is there any way to export the each XtraGrid Control to a single Excel file so that every XtraGrid information is exported to a different excel sheet. I tried setting the exporting path direction to the same Excel file, but when the first exporting process is done, the second exporting process just overrides the excel file and so on. I tried

How to release excel process?

时光毁灭记忆、已成空白 提交于 2019-11-29 12:13:23
I'm using the Excel interop and it seems to be creating a process every time I call new Microsoft.Office.Interop.Excel.Application() And never ending the process even though I call xlApp.Quit(); How can I get the processes to end? Are you releasing all of your references? (Which means you have to save them in the first place). For example here's what's in my dispose from some excel interop(): public void Dispose() { if(!this.disposed) { if(cell != null) Marshal.FinalReleaseComObject(cell); if(cells != null) Marshal.FinalReleaseComObject(cells); if(worksheet != null) Marshal

How to rename excel sheet name dynamically in C#

落爺英雄遲暮 提交于 2019-11-29 10:00:55
I have created an excel workbook with many sheets like sheet1, sheet2,... etc. How can I rename these tab names dynamically in C#? You didn't spedify how do you access the excel file. However, example from here might be useful for you if you're using Microsoft.Office.Interop.Excel . Note that it opens first sheet in the file, line: (Worksheet)xlBook.Worksheets.get_Item(1) using Excel = Microsoft.Office.Interop.Excel; object oMissing = System.Reflection.Missing.Value; Excel.ApplicationClass xl=new Excel.ApplicationClass(); Excel.Workbook xlBook; Excel.Worksheet xlSheet; string laPath = Server

Excel won't open/launch VSTO AddIn when running in debug mode of Visual Studio 2010

谁说胖子不能爱 提交于 2019-11-29 08:45:35
问题 I had previously installed the VS11 beta, and had some issues with my Visual Studio 2010 instance, which you can see here how they were resolved: Excel AddIn Click Once deployment issue. Now I have a code base which compiles/builds a vsto, which installs fine and runs fine in Excel 2010. However, when I remove the installed version from Excel, and try to run it directly through Visual Studio 2010, the AddIn does not get loaded into Excel when running in debug configuration mode, in release

Exporting the values in List to excel

穿精又带淫゛_ 提交于 2019-11-29 06:14:45
问题 Hi I am having a list container which contains the list of values. I wish to export the list values directly to Excel. Is there any way to do it directly? 回答1: OK, here is a step-by-step guide if you want to use COM. You have to have Excel installed. Add a reference to your project to the excel interop dll. To do this on the .NET tab select Microsoft.Office.Interop.Excel. There could be multiple assemblies with this name. Select the appropriate for your Visual Studio AND Excel version. Here

How to Save/Overwrite existing Excel file with Excel Interop - C#

心不动则不痛 提交于 2019-11-29 06:02:16
问题 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 place and possibly confusing to the user. I am using the workbook.SaveAs(fileloaction) method. Here

Set cell value using Excel interop

爱⌒轻易说出口 提交于 2019-11-29 05:43:05
Ok, so I'm trying to set the value of a cell with the excel interop library. I am able to do it with the following: sheet.Cells[row, col] = value; but it's terribly slow for how many I'm setting. So I'm trying to go this route: Range excelRange = sheet.UsedRange; excelRange.Cells.set_Item(row, col, value); The code executes, but no data is put in the cell. Any suggestions on what I'm missing? Thanks! Your first method should work fine for any reasonable (and a lot of unreasonable) amounts of cells, provided you have disabled screen updating ( Application.ScreenUpdating = false ). The

Writing to an existing Excel File using c#

て烟熏妆下的殇ゞ 提交于 2019-11-28 22:07:33
I am trying to open (or create a new xls) Excel file and write some values to it. Although, the program below works just fine if I simply create a new xls file, I encounter the some problem in line **mWorkBook = oXL.Workbooks.Open (path, 0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);** Here's the error: 'LOG.xls' cannot be accessed. The file may be corrupted, located on a server that is not responding, or read-only. It's not read-only, it's not corrupted(because sometime the file is created on Run Time). What is the

Eliminating use of '2 dots' when using Excel Interop Com Objects - C#

南楼画角 提交于 2019-11-28 14:25:29
I am having trouble releasing Excel Interop Com Objects which is causing my c# application to crash when I attempt to save and then close an Excel workbook created via Excel Interop. I feel the issue is that in some cases I am using '2 dots' with excel interop COM objects which from what I've read is not allowed. I have eliminated 2 dots from most lines of code, but I am having troulbe figuring out a way to recreate the following lines of code so that they only use one dot. If anyone has any suggestions I would greatly appreciate it. workbook = (Excel.Workbook)app.Workbooks.Open(startForm

microsoft.interop.excel Formatting cells

不打扰是莪最后的温柔 提交于 2019-11-28 13:25:55
I am building a report using the microsoft.interop.excel library in C#. I have something like this: Range rangeTarget; . . . rangeTarget = worksheet.get_Range("C" + row, "N" + row); I want the range to display its values as whole numbers i.e. with no decimal places. I've tried rangeTarge.AutoFormat, but have no idea how to use it. Any Ideas ? Thanks. see MSDN Microsoft.Office.Tools.Excel.NamedRange namedRange1 = this.Controls.AddNamedRange(this.Range["A1", "A5"], "namedRange1"); namedRange1.NoteText("This is a Formatting test", missing, missing); namedRange1.Value2 = "Martha"; namedRange1.Font