excel-interop

Intermittent HRESULT: 0x800A03EC errors during Excel SaveAs in .NET 2.0 app

╄→гoц情女王★ 提交于 2019-12-11 02:23:53
问题 I have a VB.NET 2.0 executable which I use to create numerous Excel files on a daily basis. Up until this point, it has been running on an XP box with Office 2007 installed (and using the Office 2007 Interop). It has worked fine for years. Recently, the box failed and it was upgraded to a Windows 7 box, also running Office 2007. After that, I started getting intermittent errors during SaveAs functions at random points in the code. What this means is that SOMETIMES the error doesn't happen at

{“Exception from HRESULT: 0x800A03EC”} at Microsoft.Office.Interop

吃可爱长大的小学妹 提交于 2019-12-11 02:19:50
问题 I am trying to create an excel file using the below code in an ASP.Net web applcation. The code works normally when I run from visual studio, but an exception occur workbook.Close command when I deploy the application on IIS and run the deployed version. Excel.Application exc = null; try { exc = new Excel.Application(); Excel.Workbooks workbooks = exc.Workbooks; Excel._Workbook workbook = workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet); Excel._Worksheet worksheet = (Excel._Worksheet

How do I “sheetwise” save or export an Excel workbook as a PDF file?

老子叫甜甜 提交于 2019-12-10 22:19:37
问题 The problem with the code I have is that either it saves all the pages in all the worksheets in the workbook or it saves only the pages in the range specified by the "from" and "to" arguments. The excel files I am working with have 7 worksheets, and each worksheet can have any amount of pages. If I specify that I want to export "from 1 to 4", for example, then only the first 4 pages of the first worksheet would be exported as a PDF document, not all the pages of the first 4 worksheets. Can

Release COM when developing an Excel Addin?

折月煮酒 提交于 2019-12-10 21:59:10
问题 I understand that I should release COM objects when using interop. Are things a bit different when developing and Add-In, Excel for example? Here is a loop I have and I was curious to know if the Marshal.ReleaseComObject is necessary? foreach (var sheet in results.Sheets) { var newSheet = workbook.AddSheet(); newSheet.SetSheetTabColor(sheet.TabColor); newSheet.SetSheetName(sheet.TabName); newSheet.Cells.SetFont("Calibri", 8); newSheet.FreezeRow(1); var endRow = sheet.Data.GetUpperBound(0) + 1

Interop Excel method LinEst failing with DISP_E_TYPEMISMATCH

折月煮酒 提交于 2019-12-10 20:07:47
问题 I am facing a problem while making Excel's LinEST function. My program goes like MyExcel.Application xl = new MyExcel.Application(); MyExcel.WorksheetFunction wsf = xl.WorksheetFunction; List<int> x = new List<int> { 1, 2, 3, 4 }; List<int> y = new List<int> { 11, 12, 45, 42 }; object o = wsf.LinEst(x, y, true, true); And the namespace is using MyExcel = Microsoft.Office.Interop.Excel; The program is compiling smoothly but at runtime it is throwing an error {System.Runtime.InteropServices

Are we unable to use Interop objects in generic objects in .NET 4.0?

泪湿孤枕 提交于 2019-12-10 17:16:09
问题 I'm working in VS 2010 and working on upgrading our application to .NET 4. The application is built with Excel as the base and we want to take advantage of some of the improvements to .NET for using Excel. But I ran across a strange error that seems to be caused by using an Excel Interop object in a generic dictionary. Here is the error that was generated: C:\MyApp\TheAssembly\MyClass.cs(823,57): error CS1769: Type 'MyApp\OtherAssemply.IMyController.SheetReports' from assembly 'c:\MyApp

How do I find which cells are selected on an Excel worksheet?

时光怂恿深爱的人放手 提交于 2019-12-10 16:43:48
问题 I need to be able to use C# and Excel interop to determine which cells are selected in a workbook/worksheet. It would be nice if there were something like this defined in Excel: Excel.Range Worksheet.GetSelectedCells(); But I don't find that in any documentation. How can I do this? tia. 回答1: Use Application.Selection which will return a Range. 回答2: I guess you can use the ActiveCell property of the Excel Application object. It would return you a Range object. HTH Rauts 来源: https:/

How to determine what “Ne” port the Adobe PDF printer is on?

夙愿已清 提交于 2019-12-10 16:38:23
问题 How can I detect what port (Ne01:, Ne02:, Ne99: etc) the printer is on? Computers (WinXP) here at BigCorp have Adobe Acrobat (version 7.0 Pro) installed which gives a virtual printer named "Adobe PDF". If you print an Excel (2003) workbook to pdf while recording a macro, the printer's full name is "Adobe PDF on Nexx:" where xx is a double digit.... and differs depending on what computer you try. I have written a C# console app using the Excel.Interop (I strongly discourage anyone else from

Display page numbers in a excel sheet generated using C#.NET

穿精又带淫゛_ 提交于 2019-12-10 14:29:36
问题 Does anyone have an idea on how to include or input the page numbers in the excel sheet generated using C# code. I use the libraries available in Microsoft.Office.Interop.Excel to generate the file. However by default in the output i cannot see the page numbers. I know to enable this via excel options (View --> Header and Footer ...) but i want to automate this via C#. Is this possible, if yes kindly share the snippet for the same. Thanks Constant Learner 回答1: If I don't know how to code

Adding buttons to spreadsheets in .NET (VSTO)

你。 提交于 2019-12-09 09:48:19
问题 Using VSTO or some related technology, is it possible to programmatically embed a button in a cell of an Excel worksheet, and configure it to call a C# function when it is clicked? How? Thanks. 回答1: With a VSTO document customization (i.e., a Workbook with .Net code attached), you can add and remove controls at runtime to the Worksheets of the project. The following code illustrates the idea: public partial class Sheet1 { private void Sheet1_Startup(object sender, System.EventArgs e) { var