excel

Excel get_Range missing when interop assembly is embedded in .NET 4.0

I build an assembly referencing a COM interop DLL. If I embed the COM interop types by setting Embed Interop Types to True in the Reference's properties (VS2010), at run-time an error occurs "object does not contain a definition for get_Range". If COM interop types are not embedded then no error occurs. Does anyone know why a particul...

How to assign certificates to excel macros programmatically

Hi, I have developed some code which creates excel macros and each time after creation of new macro I want to digitally sign the macro programmatically. Can you let me know if there is any way using which I can create new digital certificates and assign those to macro programmatically. Thanks. ...

"Attempt to read or write protected memory" with vsto 2005 addin on excel 2010

hello, I have written a vsto addin with VS 2005 for excel 2007. This addin is able to add XLL files to addin list. That works fine in excel 2007 but in excel 2010, i have "Attempt to read or write protected memory" on this call : this.Application.AddIns.Add(aAddInFullPath, Missing.Value); I have checked that aAddInFullPath is ok...

How do I exclude null rows without excluding null cells when pulling Excel into C# using SQL (ADO)?

I have a query like the following: SELECT * FROM OPENROWSET('MSDASQL', 'Driver={Microsoft Excel Driver (*.xls)};DBQ=D:\test.xls','SELECT * FROM Sheet1$]') This brings back rows that are all null if they were ever edited and then deleted. I want to exclude those, but still include rows that have good data but possible null cells. My ...

MS-Excel Negative times

I'm writing a spreadsheet for a shop manager. What it does is keep track of the number of hours a worker has worked. So you enter times for Monday-Sunday, and then an adjustment - e.g. if they work 40/40/40/32 hours for the month, then you would have an adjustment of -2/-2/-2/+6 to bring the worker to the 38 hour week that he's being ...

Adding mutiple if statements together

Im making a spreadsheet with different books people have to read and when the person gets finished reading the books they will mark and x and the box. So i have a formula for the following book columns E3,G3,I3and K3 which is COUNTIF(B3:L3,"X")*20. Can i add this formual to another so that N3 and O3 are worth 2.5? ...

How do you add two COUNTIF equations together?

How do i add two COUNTIF equations together to get a total ...

Generating Excel through .Net doing odd things

Good Morning, I have a rather odd thing happening with an Excel WorkSheet that I am creating through .Net. I load up an existing workbook Dim _xlApp As New Excel.Application Dim _xlWorkbook As Excel.WokBook = _xlApp.Workbooks.Open(_templateFileName) set it to be visible before populating it (for debugging purposes) _xlApp.Visible = T...

What is the most annoying / strangest thing that has happened to you using Excel Interop

Hi All, After developing using the Excel Interop with .Net for a while, i have become increasingly annoyed with the how many "odd things" happen - such as this question i posted earlier - My Problem. I appreciate that this is not a direct question and more of a collaberation of experiences, but i do think that it would be helpful how...

how do i convert list in reverse order in excel sheet

i have written some values in column i want to make it in reverse order .... ...

Problem copy+pasting CR+LF into an excel spreadsheet need soft paragraph (Alt+Enter)

I'm trying to copy a table that is created in our software into an excel spreadsheet. Some of the title headers in our application are too big to fit in a column so they are separated by a #13+#10 (CR+LF) so they sit on the next line. e.g. Strain SpikeConc Spike ng/g dpm/g ------------------------- Blah 20.0 5...

Excel xml spreadsheet - is it possible to embed images?

I'm trying to export data from a web app into excel, but there is a request to include the company's logo at the top of the spreadsheet. My normal method of creating the excel is to create a spreadsheet in excel and save it as an Xml Spreadsheet (Excel 2003). This allows me to build up the xml in code. However, when attempting to save t...

Using OleDB to update cells in preformatted Excel Template file

StringBuilder sbExcelFileConnStr = new StringBuilder(); sbExcelFileConnStr.Append("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="); sbExcelFileConnStr.Append(sFile); sbExcelFileConnStr.Append(";Extended Properties=\"Excel 8.0;HDR=No;\""); OleDbConnection xlConn = new OleDbConnection(sbExcelFileConnStr...

Excel VBA Dialog box with custom buttons

I would like to create a dialog box or message box in excel WITH custom button labels i.e. FIRST and SECOND. I would like for this box to open up when the file is first opened...and doesn't allow user access to the worksheet until they select either FIRST or SECOND. I can make a form, but I would rather not add a form since this should...

Get the current cell in Excel VB

I have a small script in Excel/VB that I'm trying to get working. All I want to do is select a dynamic range of data to copy but I can't seem to find any help/code on how to get the grid data (like A11). Here is code I have from macro recording that selects the range of data: Range("D291:D380").Select I was hoping I could just do ...

reversing rows in excel formulas

(A) SumProduct( A1:A3,B1:B3) == A1*B1 + A2*B2 + A3*B3 Instead, what I'm after is (B) SumProduct( A1:A3, Reverse(B1:B3)) == A1*B3 + A2*B2 + A3*B1 Is there a clean way to achieve this in excel 2003 / excel 2007 ? The natural ordering of these values is A1->A3 and B1->B3, so reversing the meanings of the cells is unsatisfactory; but cre...

How to Export data to Excel using LINQ to Entity?

Hi I have the data coming from Entity Data model table on my ASP.NET page. Now I have to export this data into Excel on button click. If it is using OLEDB, it is straight forward as it is here: http://csharp.net-informations.com/excel/csharp-excel-oledb-insert.htm Here is my function to read data from inquiries table: var model = fr...

Excel VBA Macro: create a chart from CSV?

I have a CSV file with three columns (A,B,C). I can record a Macro which selects Col A + Col B, then inserts a chart of A versus B. This works, but the code generated contains a hardcoded ref to the 'Sheet1' like this: ... ActiveChart.SetSourceData Source:=Range( _ "'Sheet1'!$A:$A,'Sheet1'!$B:$B,'Sheet1'!$A:$A,'Sheet1'!$B:$B")...

Print Fit To Width with XML Spreadsheet in Excel

I have an XML Spreadsheet that is automatically generated. There is a varying amount of Columns and Rows depending on the report. When printing I would like for it to Fit to Width (Right now if there are too many columns it will not fit on a page... even when landscape). I was initially using FitToPage but for reports with hundreds of ...

Python win32com: Excel set chart type to Line

This VBA macro works: Sub Draw_Graph() Columns("A:B").Select ActiveSheet.Shapes.AddChart.Select ActiveChart.SetSourceData Source:=ActiveSheet.Range("$A:$B") ActiveChart.ChartType = xlLine End Sub This Python (near) Equivalent almost works: from win32com import client excel=client.Dispatch("Excel.Application") excel.V...