Click here to Skip to main content
15,892,298 members
Everything / Productivity Apps and Services / Microsoft Office / Microsoft Excel

Microsoft Excel

MS-Excel

Great Reads

by Alex Pumpet
A simple program for comparing table data from two sources - SQL databases, Excel, CSV or XML-files
by yuvalsol
Create professional-looking Excels (Filters, Charts, Pivot Tables) with EPPlus
by William Hey
Classical number theories
by Bert O Neill
Query Hadoop using Microsoft oriented technologies (C#, SSIS, SQL Server, Excel etc.)

Latest Articles

by Erik Drent
A simple POCO mapper for EPPlus
by W. García
VBA solution for CSV parsing problem
by Gustav Brock
Format amounts in VBA using the Indian number format for currency and amounts
by IvanFeng
With AutoExcel, you can quickly import and export Excel without hard coding, and embrace changes.

All Articles

Sort by Title

Microsoft Excel 

21 Jun 2017 by JatinKhimani
I know that is this question has dozen of answers and posts, but nothing works for me. We have my MVC4 application and i deployed it to IIS7 to my server and one more machine where we don't have visual studio installed. We are doing import/export data from/to excel for doing bulk entry. we do...
6 Sep 2022 by mikcutu
hello,I was building an application under vb.net 2008 which worked OK.Now, I was trying to migrate it into vb.net 2010 and I still receive errors relate to different ambiguous in namespace Microsoft.Office.Interop.Excel. This is refering to DataTable, Workbook, Worksheet,...
30 Sep 2012 by Sergey Alexandrovich Kryukov
No, it is not ambiguous is you reference proper assembly. With Visual Studio, for example, you need to reference an assembly using the ".NET" tab of the "Add Reference" window. When you do it, you add the reference to the "interop" assembly for a specific Office version. You will see the...
30 Sep 2012 by Sm.Abdullah
Your Question is not clear. but take a look here it may help full for you.I had also face situation similar to this.In my case "the error is an ambiguous reference between System.Windows.Forms.Label and ZedGraph.Label"actually both of these name spaces having same class name...
1 Oct 2012 by mikcutu
well, starting from your Sergey's solution, I was looking closely to the references and saw there are few other references to Office (different versions).I just removed all of them and added the right one (Microsoft.Office.Interop.Excel) and it passed over this error....just hope this...
24 Apr 2012 by Chasfer
Hi,all friends here.As I begin to so some operation on MS excel, I was totally confuesd. If we just want to operate offis in .NET, what should we do? what if we do it on linux without Excel? As I searched on finding linq,JET,Object Model, i can't know what to do with it. when and how to use...
24 Apr 2012 by devmr
Hi, check the forum on msdn for excel developer: http://social.msdn.microsoft.com/Forums/en-US/exceldev/threads[^]
19 Dec 2013 by SkinnyGlass
Hi! I'm currently working on a financial application for a bank which requires me to compute YIELD and PRICE of securities. I know MS Excel and other spreadsheet applications have these built-in. My question is, how can I implement these functions using Visual Basic.Net?Thanks!
11 Jan 2019 by QuickBooksDev
I have a couple a VB.2010 Desktop apps that have been running successfully for years on many clients. One of my customers got a new Windows 10 PC. He installed Office 2010. When our program runs it gets the the 000245-0000-0000-C000-000000000046 80040154 class not registered error. He then...
27 Nov 2019 by biologisttryingtocode
Hi. I am trying to write a macro (for the first time ever) to move data from one sheet to the other in excel so that I can populate a table. This is my macro so far. When I try to run it it tells me "error 1004: application defined or object defined error" what am i doing wrong? ' ' Movedata...
27 Nov 2019 by Maciej Los
Try to change this: lngDestLrow = DestSht.Cells(Rows.Count, "B7").End(xlUp).Row to this: lngDestLrow = DestSht.Range("B" & Rows.Count).End(xlUp).Row + 1 Change the code accordingly to this part: 'Move Data 'DestSht.Cells(lngDestLrow + 1, "B7") = SrcSht.Range("C14") 'Enter the form Field B7...
27 Apr 2020 by The Gridlock
about a year ago, I searched this forum and I saw a sample (.NET) showing the form in a relative position compared to the specified cell, In VBA, I would need to use a fairly sophisticated API to do this, but now I can use .NET. No more...
26 Apr 2020 by Maciej Los
Check this: Control.PointToScreen(Point) Method (System.Windows.Forms) | Microsoft Docs[^]
27 Apr 2020 by BillWoodruff
PointsToScreenPixelsX and PointsToScreenPixelsY are Excel methods of a Window, or a Pane. The values returned are pixel values; to set a Form's position, you must convert the pixel values to Points. See: [^]. You can find what appears to be a...
30 Jan 2013 by ox3nt
using MySql.Data.MySqlClient;using Excel = Microsoft.Office.Interop.Excel;using System.Runtime.InteropServices;using System.Reflection;private void MySqlConnected() { #region Connect to Mysql String conString = "Data...
30 Jan 2013 by Balamurugan1989
Try this process it will work,In design form add Savefiledialog from tool box and right click that,inside the savefiledialog write the below coding,private void saveFileDialog1_FileOk(object sender, CancelEventArgs e){ DataSet dds = new DataSet(); SqlConnection con = new...
8 Jan 2014 by vishnutejcj
Please take a look at the below codepublic ActionResult SampleDownload1() { var records = _getSampleInfoQuery.Execute(); var columns = new[] { Column(x => x.College), ...
8 Jan 2014 by Pete O'Hanlon
Well, at the moment you are picking up your columns by directly allocating them as array arguments. If you are wanting to pick individual items, you're going to need to do something a little bit different - here's an example that you could adapt as you see fit:public ActionResult...
27 Sep 2013 by waliddamri1
Hi I have a strange error after catch the error "A generic error occurred in GDI+." when i try to open an excel file trought the instruction : Workbook workbook = new Workbook();workbook.LoadFromFile(FileName); but few minute after catching this exception my...
27 Sep 2013 by E.F. Nijboer
Open your Project Properties -> tab: Debugging and check "Enable unmanaged Debugging". Hopefully that will help you out with this.Update:Did you check if that excel file uses another template than the others? Has other event handlers defined that may be the problem? Also, be sure to...
27 Sep 2013 by CHill60
Some things to try ...Check that you can open that workbook in native Excel.See if any messages come up when you open it - for example, - it may be corrupt, - may have a startup macro that has a bug, - may be saved in the "wrong" version of excel. Also watch out for long path...
31 Aug 2011 by Ace_Hardlight
Hi guys and girls! I've got an issue with my exports. For some reason when i export a datagrid from vb.net to excel, the sheet has the right set of data and then directly beneath it a bunch of blank rows followed by rows with the value of #N/A. Can anyone give me a hint as to why this happens? I...
31 Aug 2011 by OriginalGriff
Answered only to remove from the unanswered list.Note to the orignal poster: It would be polite to post your solution as an answer, so other people with a similar problem can share it.
13 Jan 2021 by IvanFeng
With AutoExcel, you can quickly import and export Excel without hard coding, and embrace changes.
21 Jun 2017 by Mcbaloo
I get the above error while trying to upload excel sheet to datagrid. After series of debugging, it throws the error just when it gets to the "Connection.Open()" section of my code, Below is my code What I have tried: protected void btnUpload_Click(object sender, EventArgs e) { ...
21 Jun 2017 by Karthik_Mahalingam
check this thread External table is not in the expected format.[^] Microsoft.ACE.OLEDB.12.0 'External table is not in the expected format' error on Windows 2003 server[^]
1 Dec 2010 by Brian C Hart
A class that accepts a reference to an Excel.Worksheet and lets you use an overloaded subscript operator to cleanly and intuitively read/write the Value2 of Excel cells, and get the Excel.Range corresponding to a given cell.
3 Sep 2010 by henry_sea
I get a string from other program. Then I put it into the Clipboard.In the String one of the data use "\r\n" as separator. So my problem as follows:I want the string import a column of excel ,my codes : Sheets sheets = m_wb.GetSheets(); _Worksheet ws =...
4 Sep 2010 by Niklas L
Verify nBufLen count includes the terminating null character, and that you build using UNICODE.Be careful what functions operate on bytes and what operate on TCHAR. Since it looks like you're using UNICODE, make sure nBufLen is in bytes and not in TCHAR count. Otherwise you might have to...
5 Sep 2010 by henry_sea
dear Niklas, the problem isn't nBuflen , I do this like you formerly .So I want to know the range.PasteSpecial(XLPASTEALL, XLPASTESPECIALOPERATIONNONE, KK_OleVariant((long)FALSE), KK_OleVariant((long)FALSE));is right ?
17 Apr 2011 by alijoongolgoli
Hi,I have developed an ASP.Net project in which I want to produce some excel reports. When I run this program on my local system, there is no problem in viewing those excel files, but after putting that software on server (Windows Server 2003 r2) I can not view the reports and I get the...
18 Apr 2011 by thatraja
Here you go for the solved solutionProblem in Microsoft.Office.Interop.Excel[^]Update----------------------------It's a permission error....apply the below steps(Copied from above link), that's allStep 1 : Go to run type dcomcnfgStep 2 : Click >Component services >Computes...
12 Apr 2011 by OriginalGriff
If you have checked that the server has enough memory and disk space, then the best guess is that it is a permissions issue. There is a discussion of this problem with various solutions you can try here[^]
17 Apr 2011 by DipaliKolhe
Microst doesn't reccommend to use Interop.Excel for server programming.Use OpenXML instead.[edit]DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously. -...
16 Dec 2013 by Stefan Huy
For those who badly miss a .NET like List in VBA
16 Jan 2016 by Glenn Lloyd
This is an alternative for "A Simple List Class for VBA Projects"
1 Nov 2012 by Pasan Eeriyagama
This article focuses on a Very simple and Robust way to export Data to EXCEL
18 Aug 2011 by Herre Kuijpers
A utility that allows you to enter simple and more complex mathematical formulas which will be evaluated and calculated on the spot
24 Feb 2019 by WhiskeyBeforeWater
An unbalanced basic recursive Binary Search Tree for Excel VBA with functions (insert, search, delete, in order, pre-order, post-order, minimum, and maximum)
16 Mar 2019 by WhiskeyBeforeWater
A nodular Singely Linked List for VBA with some basic functions
16 Jun 2011 by Member 7940184
In Excel 2003 any events are there???which matches with Cell_leave event Thank U for ur replies..
17 Jun 2011 by S Houghtelin
You can try to use selectionChange event.You can evaluate which cell has current focus and keep track of last cell range that had focus prior to the current cell range.Private Sub Worksheet_SelectionChange(ByVal currentRange As Range)Static lastRange As Range If Not lastRange Is...
23 Mar 2011 by Muhammad Aamir SumSum
My Qustion..Table NameJ_voucherFields are:Voucher Number, Date , Narration , Debit , CreditAutonumber on Voucher Number:I want Autonumber Like That JV-TodayDate-000AutoNumber
23 Mar 2011 by OriginalGriff
Access provides autonumber: it is called an "autoNumber" field, surprise, surprise. Also unsurprisingly, it is numeric only...I would keep the Voucher code separate: The Voucher number is the Autonumber field, the Date field is the TodayDate, and build the voucher code from that using...
24 Jan 2011 by maccaro
Hii'm developing a VBA application in Access 2007. To run the project, I have to include the "excel 12.0 object library" by selecting it in the "add reference" dialog. The problem is that if i go to the add reference menu, i can't find any library. The dialog is empty. where can i find the...
24 Jan 2011 by maccaro
There are no tabs in the dialog...
24 Jan 2011 by gammagtmw
Is the "COM" tab really empty? Seems unlikely to me.Open the "Add Reference" dialog, switch to the "COM" tab and scroll down to "Microsoft Excel 10.0 Object Library".
24 Jan 2011 by maccaro
Thanks to all!Solved by using the menu in the VBA window instead of the Access one.
16 Jun 2016 by Member 12586997
Hii,I have created a visual studio 2015 ASP.NET 4.5 web application project. I can access it from visual studio with IIS express. I just want to put this link inside a excel arc, and access it without openning visual studio. Can you do it without installing IIS?ThanksWhat I have...
5 Sep 2011 by Totalo Doto Neto
HiMy Asp.Net 4.0 application is working fine in Window 7 32 bit development box but when i deployed it in Window 2008 R2 64 bit server (IIS 7.5), I cannot able to access excel 2010 file using microsoft.ace.oledb.12.0I have shared hosting plan and cannot able to install drivers on server....
5 Sep 2011 by Abhishek Sur
I think it is COM based API so needs installation. Why dont you speak with your Vendor, just dropping him a mail to update his server with latest drivers? To access this driver from a 64 bit machine you can use This tutorial[^]
16 May 2013 by waris kantroo
I have created a webquery in excel which fetches data from the webpage in Excel file. Is there anyway i can access the same webquery in C#. I hope it makes sense. Need some valuable suggestions with the coding
16 May 2013 by Amey K Bhatkar
yes it make seance.I am forwarding you the MSDN link that might help you.http://office.microsoft.com/en-us/excel-help/get-and-analyze-data-from-the-web-in-excel-HA001054848.aspx[^]
16 Jun 2011 by T2102
I am getting an access violation when I try to get the Excel caller when I evaluate a defined name that equals a UDF of another defined name.In particular, I am getting an access violation when I try to find the Caller.Is there a way I can tell whether the access violation is from Excel...
16 Jun 2011 by OlegKrivtsov
You can attach to the Excel.exe process with the help of Visual Studio. In your Visual Studio window, open menu Debug->Attach to process.. and select Excel.exe in the list. Then do what you typically do. When excel crashes, Visual Studio will show you the Call Stack window and you will be able...
16 Mar 2011 by MohamedHassanAli
Hi,I have created an web application which takes three excel files from the client side which compares and processes those excel sheets and then updates the same excel sheet. I have used ODBC provider.After deploying the application over a server the file upload control takes the path of...
16 Mar 2011 by Micha3ldg
If you are really sure about the excel as your backend.Try this to add into your appconfig section in app.config or web.config file.Examplein your code behind add thisstring constr = ConfigurationManager.Appsettings["ExcelConnectionString"];this way you can always...
12 Dec 2011 by surakesh
using Excel = Microsoft.Office.Interop.Excel;namespace program{ private void cmdOpen_Click(object sender, System.EventArgs e) { FileSystem.FileOpen(1, inputfile, OpenMode.Input, (OpenAccess)(-1), (OpenShare)(-1), -1); // 1 : excel file Excel.Application MyXl; MyXl = new...
14 Dec 2011 by E.F. Nijboer
MyXl is declared in cmdOpen_Click and should be passed to Variables, otherwise it will be undefined.public void Variables(Excel.Application MyXl)Also, about the next line:object ws;Use specific type declaration for other excel classes like workbooks and worksheets:Excel.Workbook...
14 Dec 2011 by NandaKumer
check these blogshttp://social.msdn.microsoft.com/Forums/en-US/Vsexpressvcs/thread/9c2d6d93-314c-4ddb-88e8-638c0edfe62b/[^]http://msdn.microsoft.com/en-us/library/dd264733.aspx[^]--NDK
1 Jun 2011 by M Bester
HiBusy creating with a little program that creates a excel spreadsheet from a sql database but hit a little snag.Trying to access the text from a datetimepicker in my MainForm class from my CreateExcelClass (seperate .cs file). Tried a few examples I found around the web, didn't work so...
1 Jun 2011 by BobJanova
You probably want to use DateTimePicker.Value, not Text. However, what you have there appears ok. The problem is that you are creating a new MainForm, not passing a reference to the one you are actually editing controls in! Somewhere, you need to pass an instance of the main form you are using...
1 Jun 2011 by erwrwrwr
You can see all the opened forms with the Application.OpenForms, loop through all the formsforeach(var f in Application.OpenForms.OfType()){if(f is MainForm){ (f as MainForm).GetWaterStartDate();}}
16 Mar 2012 by RDBurmon
Does any one have solution on this issue ?Ad hoc access to OLE DB provider 'Microsoft.Jet.OLEDB.4.0' has been denied. You must access this provider through a linked serverI am getting this when tried to below query from SSISInsert into OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel...
19 Mar 2013 by balkha7
I have a worbook name 'student' it has 1 to 60 sheets. I have selected cell No.B2 of all sheets. I want to change formula in B2 cells of all 1-60 sheets. The formula in sheet1 cell B2 is =[sub.xlsx]Sheet1!$B$2 in sheet2 the formula should change...
21 Mar 2013 by Maciej Los
See past answers and never again repost, OK?want a excel formula or vba for link cells across multiple sheets same cell[^]link cell formula or code to paste link across[^]
31 Mar 2016 by Miguel Altamirano Morales
I want to add a calculated field in a pivot table in excel. I know how to do that, but this time i have to colour red or green this field, depending of the value of a resulting previuos calculated field. If the result is positive the new field must be green, if not, red.I have not been...
31 Mar 2016 by CHill60
You need to use "Conditional Formatting" to do that ... FormatConditions.Add Method (Excel)[^]
5 Nov 2014 by nikhilkhoda
I have a code as below. I want to add a line break randomly after few lines.. How can i add that. Below is the code which i have done but don't know how to add a line break.sbGenerateExcel.Append(" "); ...
5 Nov 2014 by Mukesh Ghosh
Line break generally done by tag but i am not sure your purpose. Let meknow if it's work for you.
24 Dec 2010 by RoUsbelle
Hello!I have an xslt and I have an excel file with format. I need to add an autofilter to the second row which has the table headers.I've tried addingas described by XML Excel Reference, but it's not working.I...
12 Feb 2012 by YKK Reddy
Hi All,I have a requirement in my project to add multiple images on the fly. The images are dynamically obtained from another source (the image path is obtained) and i need to paste them at a particular location on the excel sheet.I am able to add single image successfully to spreadsheet...
13 Feb 2012 by YKK Reddy
Hi,I have solved it myself. I am posting it here just in case anyone else needs.I modified the code for the "Drawing" class. The below code is mentioned:if (imageNumber == 1) { Drawing drawing = new Drawing() { Id = "rId" + drawingPartId.ToString() }; ...
13 Mar 2012 by comred
Hi,I am making an Add-In for excel in .Net.I referred an article available on code project i.e. Create an Automation Add-In for Excel using .NET[^]I build the dll, but when I tested it on excel its give me error as"abc.dll is not a valid office Add-InI am trying to do it in...
13 Mar 2012 by Prerak Patel
http://social....
13 Aug 2012 by Sachin Chandanshive
Addin Containg Useful Macros & Easily Accessible From Ribbon Menu
28 Dec 2018 by Member 14100488
I'm trying to make an C# Excel addin in order to automate the calculus of some cells value.What the addin should do is when a box is checked it should multiply the value of a cell with other cells and paste the result in different cells.The error that I get is "Cannot convert null to int because...
28 Dec 2018 by Maciej Los
The best way to resolve your issue is to use debugger[^]. As to the first error message: Quote: Cannot convert null to int because it is not a non nullable value type Yes, this might means that sheet.Cells[1, 12].Value2 holds nullable value. As to the second error message: you don't need to...
12 Jan 2021 by ahmad shahoseini
We have a woocommerce shop site and we want to add category and description field to any products row (variations and variables)in our excel exported product file, now the category field and description field exist just for variables and not...
12 Feb 2012 by YuMih
I need to put a comment in a cell.Both data came from my database.I'm using sb.Append and html tables to generate report to excel.Is this possible?Thanks in advance.
12 Feb 2012 by Ganesan Senthilvel
Two ways you can achieve it. First solution is manual operation as: Take your simple html file and open it in Excel. Add a comment to a cell. Save it, preserving the html format.Second solution is through code as: xmlns:office="urn:schemas-microsoft-com:office:office"...
26 Dec 2012 by SadiqMohammed
I have a SSIS package in which I've added a Script Task. In the Script Task I've given a oledb connection manager and acquired a data table from the database and the query is just working fine. Now I have to put the data table into an excel file. This is the primary solution I need to arrive at....
28 Dec 2012 by SadiqMohammed
Hurrrrraaaaaaayyyyyyyyyy!!!!!!...
15 Dec 2015 by Member 12208071
I have a column in excel file contain 100 row I'm trying to import this column into listbox using a buttonThe problem is that only 48 row is importing from the excel column .why not all rows inside the column are imported?here is my code (vb.net form)Private Sub...
15 Dec 2015 by CHill60
If you look at the edit to my solution to your previous post importing from excel to listbox[^] you will notice that I have already explained what the problem isTo reiterate, the for loop For i = 0 To AscW(ListBox1.Items.Count.ToString()(i = i + 1)) - 1is only looking at items that are...
12 Oct 2011 by jldmen
Everything I've seen on this subject pertains to clock time, as in what would the time be if I added 30 minutes and 29 seconds to 3 PM? But I've yet to see a question or answer that addresses my particular requirement.Here it is. I'm trying to use Excel to add up and total the timings of...
12 Oct 2011 by Sergey Alexandrovich Kryukov
I just tried it: as I expected, it works in Excel without any "calculators".If works if you simply add time using strings like "dd:dd". The sum is calculated correctly, but if you look at the cell type, it's not "mm:ss" (minutes and seconds), but "hh:mm" (hours and minutes). What's the...
26 Jan 2016 by Developer It
hi iam trying to select sum of total in excel sheets and add it into a list box each one of them in a new linehere is my codeprivate void btn_update_Click(object sender, EventArgs e) { for (int i = list_sheetnames.Items.Count -1; i >= 0; i--) { ...
26 Jan 2016 by Richard Deeming
Quote:list_total.DataSource = da.ToString();You're setting the data source of the list to a string containing "System.Data.OleDb.OleDbDataAdapter". You need to set it to the data returned by the query instead:list_total.DataSource = sheetInfo;
15 Feb 2012 by YKK Reddy
Hi All,I am using OpenXML SDK 2.0 and i am having a requirement that i need to insert an image into a particular cell and adjust the cell width and height (in other words corresponding Row Height and Column Width) according to the image Horizontal and Vertical Pixels.I am planning to use...
15 Feb 2012 by YKK Reddy
Hi All,After many attempts, i finally found out the solution. Thought of sharing with you guys.int iImageWidth = 0, iImageHeight = 0, iOffset = 10; using (Bitmap bitmap = new Bitmap(strImageFile)) { iImageHeight = bitmap.Height; ...
12 Mar 2014 by anuragsapanbharat@gmail.com
HI,I have been trying to create a ADODB connection to an Excel 2010 files located in a web location. But my connection string s not working.Dim con As ADODB.ConnectionDim rs As ADODB.RecordsetSet con = New ADODB.ConnectionvPath =...
12 Mar 2014 by Maciej Los
Please, have a look here: How To Use ADO with Excel Data from Visual Basic or VBA[^] and follol the instructions. If it won't help, i need to warn you that there are known issues with x64 machines:Could not find installable ISAM[^]Accessing Excel files on a x64 machine[^]Finally, i'm...
16 May 2013 by chenduran10
How can I make the export more faster.this one is too slow..
14 May 2013 by CHill60
To improve performance you need to minimise the use of the Excel COM interface.I would suggest converting your list of objects to a datatable first and then exporting that to excel ...Here is a generic way to convert a list to a datatable Converting a List to Datatable[^]and here's how...
14 May 2013 by Maciej Los
If you fetching data from database, the fastest way to export data is to use CopyFromRange()[^] method for MS Excel range.More about: How to transfer data to an Excel workbook by using Visual C# 2005 or Visual C# .NET[^]
23 May 2018 by yuvalsol
Create professional-looking Excels (Filters, Charts, Pivot Tables) with EPPlus
22 Dec 2011 by Member 7949711
Hi all,I exported data to excel using the following link by Yogesh Jalota.A Very Easy to Use Excel XML Import-Export LibraryMy problem is I don't know how to align columns to center.I posted my query in the same post but have not got response.Any suggestions will be...