excel-interop

Fastest method to remove Empty rows and Columns From Excel Files using Interop

ぃ、小莉子 提交于 2019-12-17 03:40:49
问题 I have a lot of excel files that contains data and it contains empty rows and empty columns. like shown bellow I am trying to remove Empty rows and columns from excel using interop. I create a simple winform application and used the following code and it works fine. Dim lstFiles As New List(Of String) lstFiles.AddRange(IO.Directory.GetFiles(m_strFolderPath, "*.xls", IO.SearchOption.AllDirectories)) Dim m_XlApp = New Excel.Application Dim m_xlWrkbs As Excel.Workbooks = m_XlApp.Workbooks Dim m

Fastest method to remove Empty rows and Columns From Excel Files using Interop

落爺英雄遲暮 提交于 2019-12-17 03:40:43
问题 I have a lot of excel files that contains data and it contains empty rows and empty columns. like shown bellow I am trying to remove Empty rows and columns from excel using interop. I create a simple winform application and used the following code and it works fine. Dim lstFiles As New List(Of String) lstFiles.AddRange(IO.Directory.GetFiles(m_strFolderPath, "*.xls", IO.SearchOption.AllDirectories)) Dim m_XlApp = New Excel.Application Dim m_xlWrkbs As Excel.Workbooks = m_XlApp.Workbooks Dim m

Excel interop adding slashes in my number formatting string

有些话、适合烂在心里 提交于 2019-12-14 03:14:42
问题 I'm trying to set a number format (South African Rand currency, no decimals) to a range like so: range.NumberFormat = "_ R * # ##0_;"; where range is of type Microsoft.Office.Interop.Excel.Range however when I open the spreadsheet and check the formatting string by choosing custom format the string now looks like this: _ \R * #\ ##0_; and these added slashes means that only the first thousand separator (a space) is present and the rest are left off. I've also tried this: range.NumberFormat =

How can I call System.Runtime.InteropServices.Marshal.ReleaseComObject from within an Excel 2007 VBA module

六月ゝ 毕业季﹏ 提交于 2019-12-13 19:11:27
问题 I want to call System.Runtime.InteropServices.Marshal.ReleaseComObject(obj) on some 3rd party COM objects that I've instantiated in my VBA code, from my workbook close event, something like the following: Public Sub disconnect(obj As Variant) Dim refs As Long refs = 0 If Not obj Is Nothing Then Do refs = System.Runtime.InteropServices.Marshal.ReleaseComObject(obj) Loop While (refs > 0) End If End Sub However, I get a compile error: invalid qualifier with the System highlighted with the above

How can I get the members of a PivotTable column field to display in natural order, rather than alphabetically?

与世无争的帅哥 提交于 2019-12-13 15:27:26
问题 I was taught how to convert a date-as-string value that was being converted from what I wanted ("Sep 2015", "Oct 2015" etc.) to what Excel thought it should be ("15-Sep", "15-Oct" etc.) here. When it was displaying "badly," the columns at least displayed in the right order ("2015-Sep" followed by "2015-Oct"). Now that they are "Sep 15" and "Oct 15", though, they are displaying out of "natural" order and in alphabetical order ("Oct 15" followed by "Sep 15"). This is the too-typical scenario

Excel exception HRESULT: 0x800A03EC from ChartArea.Copy()

假装没事ソ 提交于 2019-12-13 12:21:40
问题 I'm working on a C# Application thats interacts with an Excel instance using excel interop.dll v11.0. I'm using the following code to copy a chart from the excel worksheet to the clipboard: public Image ReadChart(Chart chartAccess) { try { Microsoft.Office.Interop.Excel.Worksheet sheet = workbook.Sheets[chartAccess.Sheet.Name]; Microsoft.Office.Interop.Excel.ChartObject chart = sheet.ChartObjects(chartAccess.Name); chart.Chart.ChartArea.Copy(); // exception gets thrown here return System

Why Excel.WorkSheet.Copy throws exception of A first chance exception of type 'System.Runtime.InteropServices.COMException' with HRESULT: 0x800A03EC

拟墨画扇 提交于 2019-12-13 07:50:39
问题 I am playing around with Excel Interop in .NET where I am encountering COMException over "Excel._WorkSheet.Copy(Type.Missing,Type.Missing)". The behavior is very strange : I am copying worksheets from a template based .xls and generating a new workbook with specified worksheets( probably selected by user from GUI ). As soon as it encounters Excel._Worksheet WorkSheet.Copy(Type.Missing,Type.Missing), it throws following COMException. "A first chance exception of type 'System.Runtime

Excel Interop C# Can't add VBProject Error 800A03EC on Workbook.VBProject.VBComponents.Add(..)

人走茶凉 提交于 2019-12-13 07:17:31
问题 I) Global Explanation Hello, I'm developing an app in C# using Microsoft.Office.Interop.Excel. In my case I implement some olds macros stored in a file to an Excel Workbook, opened by C#, to upgrade them without re-coding macros in my app. Globally there is my process in my app : The user select an updated macro, I check if the macro require something : Here I set the register Key CURRENT_USER\SOFTWARE\Microsoft\Office\[office_ID].0\Excel\Security\AccessVBOM to 1 for allows macro/VBProject

ComException When trying to delete a worksheet from an Excel File in C#

守給你的承諾、 提交于 2019-12-13 07:15:19
问题 I'm running into an Odd problem that I cant seem to find a solution for. I'm trying to delete any work sheet in a workbook that contains a certain worksheet name and I keep getting this exception: "Unable to get the Delete property of the Worksheet class" I'm able to use the worksheet class in other places but when i try to use the Delete(); method, or even the one that sets the visibility of said sheet I get the same thing. Any help as to why would be appreciated! Microsoft.Office.Interop

Excel interop conditional formatting with formula

守給你的承諾、 提交于 2019-12-13 05:38:53
问题 I have two scenario, I'm developing with two pc, one with Visual Studio 2010, Office 2010, PIA 2010 and another PC with Visual Studio 2010, Office 2007, PIA 2007. The same application have different behaviour, the first one works fine, the second one doesn't work. I need to set a conditional formatting in a spreadsheet but with office 2007 it doesn't work because the formula in Excel is copy as string and not as formula. My code is the following for both office version: Excel.Range cellToSet