Click here to Skip to main content
15,891,951 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 Updated

Microsoft Excel 

6 Apr 2010 by #realJSOP
The only way I can think of doing this is to use the MS Office automation stuff, but I have no experience in doing that (and don't know anyone that has done it - or wanted to). Google is your friend.
6 Aug 2010 by #realJSOP
How is the data displayed in the html? Using a table? If so, you could just get the table from the html, and at that point, put it into a XElement. From there, you could use LINQ to get all distinct rows.
15 Dec 2010 by #realJSOP
Maybe Excel doesn't support dates earlier than 1900... have you googled it?EDIT ==============I googled it, and found out that the earliest possible date Excel will accept is 01/01/1900. You're out of luck, Sparky. Here's the link I found the info...
28 Dec 2011 by #realJSOP
First, you need to retrieve the data from the spreadsheet - one row at a time. Once you've retrieved the data, THEN you manipulate it as desired. After that, you can insert it into your table. The short version is that you have to break your process into steps so that you can actually control...
6 Oct 2016 by #realJSOP
Calling COM Components from .NET Clients[^]
14 Oct 2016 by #realJSOP
First - and this is just a personal opinion - most of your variable names suck.Second, you have to split the string, and then re-assemble it.// a sample formulastring cha = "=SERIES(Trend_NCM!$A$3,Trend_NCM!$B$2:$AH$2,Trend_NCM!$B$3:$AH$3,1)";// split the whole string on...
19 Oct 2016 by #realJSOP
You also need to encapsulate a field with double quotes if the field itself contains one or more double quotes.
25 Nov 2016 by #realJSOP
Here's a class I wrote to load Excel files. It compiles and works as intended (I'm using Interop v15 I think, but that shouldn't have any impact on this code) Feel free to modify to meet your requirements:using System;using System.Collections.Generic;using System.IO;using...
28 Nov 2016 by #realJSOP
You can't get the last row used in a specific column without iterating the range of cells (from [column]1 to myWorksheet.UsedRange.Rows.Count) BACKWARDS until you find the last row with a value. If you just want the number of rows used overall, use myWorksheet.UsedRange.Rows.Count
15 Dec 2016 by #realJSOP
Yeah, you English isn't helping us, and I'm assuming you're using Excel.Interop to open the Excel file.I think you need to look at the Worksheet.UsedRange property.
22 Mar 2017 by #realJSOP
I'm starting with a file that:0) Contains one or more sheets1) The names of the sheets are not guaranteed to be the same, but the columns in them are always the same2) The header row is row #5 (and there is data above this row that I don't want to import).Essentially, I need to...
3 Apr 2018 by #realJSOP
Change your stored procedure to replace nulls with reasonable default values.
7 Jul 2018 by #realJSOP
If you have a datatable, you can save it as a xml file using the DataTable.WriteXML() method, and then open that file in excel.
7 Sep 2018 by #realJSOP
You can configure the sheet to pull data from the database. Google is your friend. excel data connection - Google Search[^]
4 Nov 2018 by #realJSOP
I did this google search - c# vsto excel add-in[^] I don't know if any of the links will help, but most of the first 20 links were dates within the last two years.
21 Mar 2019 by #realJSOP
Use the FileOpen dialog box. Sub SomeButton_Click(sender As Object, e As EventArgs) Handles SomeButton.Click Using dialog As New OpenFileDialog If dialog.ShowDialog() DialogResult.OK Then Return File.Copy(dialog.FileName, newPath) End Using End Sub I'll leave it up...
2 Apr 2019 by #realJSOP
If you want a spreadsheet in your app, there are a couple of libraries you can use, but if you want guaranteed compatibility with Excel formulas and macros, you'll have to spend money. Telerik, Infragistics, DevExpress, and SpreadsheetGear, are all viable choices, but they all cost money. There...
12 Jun 2020 by #realJSOP
I use a parser called ExcelDataReader. It's available via NuGet. Depending on the size of your files, it still may not be adequate, though. You'll have to make that determination on your own. EDIT ======================== I wrote an article and...
7 Jun 2016 by .NET Developer66
I need to know the FONT in the excel file which i have to read?What I have tried:1) string ExcelFont = workBook.Styles.Item.Font.FontStyle.ToString();2) string ExcelFont = workBook.StandardFont;
14 Nov 2014 by .Net Jim
Check this out...Faster MS Excel Reading using Office Interop Assemblies[^]
10 Jan 2015 by .Net Jim
There are a variety of ways to do this. That said there are a few key questions to shape your choices. First, can your users learn to import the xml into Excel? Excel has been able to import xml for over a decade. The key to doing this successfully is to avoid attributes in xml. Just name...
27 Mar 2017 by .Net Jim
Excel c# convert cell to percentage - Stack Overflow[^]
30 Jul 2012 by 0aFzaL
Hi,I was looking for a kind of Software that would allow me to generate bulk HTML Files, according with the data. At The moment I am using Lotus Domino from IBM, but it is returning some errors, and I don't know what else to change. I was looking for an alternative software that could allow...
14 Nov 2022 by 283
using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Web.UI; using System.Web.UI.WebControls; using ClosedXML.Excel; namespace JqueryTutorial { public partial class WebForm1 : System.Web.UI.Page ...
22 Jun 2011 by 2irfanshaikh
Check the link given below:A Fast CSV Reader[^]
23 Jun 2011 by 2irfanshaikh
Instead on Spaces put Tabs between the two columns
24 Sep 2012 by 77Jeff
How can I use Excel COM C# to copy non contiguous ranges and paste those ranges to another WorkBook? The Sheets cannot have other cells outside of the defined ranges affected. Some of my Destination Ranges will be different than the Source Ranges. Here is some of my code. It gives compiler...
22 Jan 2015 by @SkyHigh34
I am currently autofiltering a range of data, I copy my filtered data to a new named range.When I run the code below; in my userform Listbox, I get a row from the source range outside of my identified range below "rlist" with duplicated results inside the listbox around 50 time? thank you in...
29 Aug 2012 by __TR__
Try using the Match[^] function. http://spreadsheets.about.com/od/lookupfunction1/ss/2011-03-01-excel-2010-match-function.htm[^]http://www.techonthenet.com/excel/formulas/match.php[^]Hope this helps.
20 Nov 2013 by __Vano
http://stackoverflow.com/questions/10957715/open-excel-workbook-from-memorystream[^]
31 Jul 2012 by _Amy
Hi,Try this:This below function used to generate excel file based on datatable.public void ExportToExcel(DataTable dt){ if (dt.Rows.Count > 0) { string filename = "DownloadMobileNoExcel.xls"; System.IO.StringWriter tw = new System.IO.StringWriter(); ...
31 Oct 2012 by _Amy
Use Table valued parameters to save bulk data from gridview. Refer the links below for an article:Sending a DataTable to a Stored Procedure[^]C# and Table Value Parameters[^]Table-Valued Parameters[^]Use Table-Valued Parameters (Database Engine)[^]Hope it helps!      --Amit
19 Feb 2013 by _Amy
Try this:Response.Clear();Response.AddHeader("content-disposition", "attachment;filename=filename.xls");Response.Charset = "";Response.Cache.SetCacheability(HttpCacheability.NoCache);Response.ContentType = "application/vnd.ms-excel";System.IO.StringWriter stringWrite = new...
8 Aug 2012 by _andrew1978
Hi fellow programmers,I have a small problem with which I need some advice/help with. I have an application that populates cells in an Excel spreadsheet that contains 4 charts, each of which is linked to the populated cells. The populated template is then saved as a new file (eg...
15 Mar 2011 by _Ashish
try this on button click Response.Clear() Response.AddHeader("content-disposition", "attachment;filename=FileName.xls") Response.Charset = "" Response.Cache.SetCacheability(HttpCacheability.NoCache) Response.ContentType = "application/vnd.xls" ...
26 Feb 2014 by _Asif_
Check this URLTrigger not working on SQL import export wizard[^]
25 Feb 2015 by _Asif_
Check this thread Any equal function in sql server for NORMSINV(probability)[^]
25 Feb 2015 by _Asif_
Try putting below in the target column=CONCATENATE(Column1, "=", Column2)
18 Nov 2013 by _Damian S_
Have you tried something like this?rowz[i].Cells.Font.Bold = true;
5 Feb 2015 by _Geoff
I know it has been two weeks since you posted, but fwiw, I think this could help.Using a step value of 15 in a for loop and incrementing the starting value in each iteration should take care of what you need easily. This first code is hard coded with the values you provided and should be...
24 Feb 2015 by _ivy
In my Windows Form I have 3 DataGridView placed within a TabControl. All I can do as of now is to export the DataGridView content to a new excel file with 3 sheets. But then I am also ask to append the content of each DataGridView to an Excel master file with 3 sheets as well. Any Idea on how to...
3 May 2013 by _Marshall
Without being able to see your data this solution is a good starting point.Public Sub coltorow()Dim rng As RangeDim i As Long, newSheetRow As LongDim rngValues()Dim lastrow As Long''Variable to keep track of row on new sheetnewSheetRow = 1''Determine last row of data on...
21 Feb 2011 by _Maxxx_
This is all guesswork -)Are you sure that is actually what you are seeing... i.e. .you start with"MNODays"and finish with"LLM Days Hours"If so, then something seems to me to be horribly wrong!I'd break it down and just have the first replace and look at the results - if you get...
29 Apr 2013 by _ProgProg_
Hey Guys,i've a serious situation,My Client gives me an excel file for some data.The excel file is exported from Crystal Report of another application that i don't have autorization to edit in it.He wants me to add a page to my website that could upload and insert these data...
29 Apr 2013 by _ProgProg_
thanks Guys i've solved it my selfi've convinced my client to put the data in some kind of a template file
7 Jul 2018 by _ProgProg_
Dears, I want to download a DataTable Data as Excel 2013 File Not excel 2003. Here is my code: private void DownloadExcelReport(DataTable dtResult) { var gv = new GridView { DataSource = dtResult }; gv.DataBind(); ...
31 Dec 2015 by _Tuba
I'm trying to open excel file in datagridview ,the problem when I choose file doesn't show all file in datagridview ? OpenFileDialog op = new OpenFileDialog(); //tool to open the file op.Filter = "ALL Files |*.*|Excel Files |*.XLSX"; //select the type of file that want open...
26 Feb 2013 by A Roychowdhury
Hi,Am new to VB.Net. I have created a windows service. Where my simple goal is to create an Excel file and save it to my local drive. I have used the following code. Dim oExcel As Excel.Application Dim oBook As Excel.Workbook Dim oSheet As Excel.Worksheet ...
27 Jun 2014 by a7med ssss
hiiiiiiiiiii,,How Import data from Excel file to sql server in c# windows form ???
27 Jun 2014 by a7med ssss
look for this error that appear when connection is openCould not find installable ISAM.
19 May 2017 by AAB40
Hi, I'm trying to add an XML file in my excel workbook on sheet 2 to create pivot tables. Everytime that I import an XML file, another excel workbook is opening. How can I change this please? So, to make my actions clear: Open Excel on sheet 1. Click 'Open folder' in the start menu of the excel...
29 May 2017 by AAB40
Hi, I went a week on vacation and apparently it did me a good thing. It works now. Added the code in a new excel sheet and the uploaded XML file is opening in sheet 2.
30 May 2017 by AAB40
When I'm running my code I have a runtime error on Sheets2.UsedRange.Columns.AutoFit could someone tell me why please? The reason of this ActiveX button click is to select all cells in sheet 2, autofit the columns and select particular columns to change the font of it. Thanks in advance. What...
29 May 2017 by AAB40
I've made it to add an xml file in sheet 2 of the present workbook in excel using VBA. Though every time I click the button, excel is nevertheless adding a workbook in my Original workbook. How can I code this for it not to happen anymore please? What I have tried: Private Sub...
17 Feb 2016 by aakar
Hi All,I have my data in the below format in an excel sheet.Location Dept_Name Alloc%New York Finance 50.00Stockholm IT 45.00Geneva Services 30.00New York IT 50.00Stockholm Services 45.00Geneva IT 60.00Stockholm Finance...
17 Jul 2015 by Aakash Bashyal
My SQL Database Has field name [Name],[Roll No],[Score] . The Score Field is NULL. i want to select all the row of Excel sheet i.e [Roll No],[Score]. And after the selection i want to iterate to the loop and Check if the Roll No of the excel and Roll No in sql database is equal. if it is equal...
23 Jul 2012 by Aarti Meswania
Imports MicrosoftImports Microsoft.Office.Interopand add reference dll "Microsoft.Office.Interop.Excel"function to export data is given below''' ''' Write Excel file as given file name with given data. ''' ''' full file...
13 Sep 2012 by Aarti Meswania
dim Filepath= "E:\Live.xls"Dim cn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Filepath & ";Extended Properties=""Excel 8.0;"""Happy Coding!:)
27 Aug 2013 by AASHUTOSH ACHARYA
Hello,I am trying to sync excel with a SharePoint list on the same site. The excel file is uploaded in document library but not getting updated when I am making any changes in SharePoint list while opening in excel services wherein it works fine when I open the file with office client...
23 Jun 2010 by aasser
Hi,How can I past an image in Cell[5,3] of an excel worksheet by C#?Please Do NOT express your opinion if you have not enough knowledge about it or you are not sure about that.Please Do NOT send any other link searched by google, because there are a lot of non working example on the...
22 Jun 2010 by aasser
:thumbsup:I could solve it: Excel.Range oRange = (Excel.Range)xlWorkSheet1.Cells[Row, 1]; float Left =(float) ((double)oRange.Left); float Top =(float) ((double)oRange.Top); const float ImageSize=32; ...
2 Sep 2013 by aatish442000
private void toolStripMenuItemMcDonald_Click(object sender, EventArgs e) { try { ////saveData(); string ndocPath = String.Empty; OpenFileDialog dlgOpenFile = new OpenFileDialog(); if...
16 Sep 2010 by aayu
When changing the connection string of a linked table, you must then refresh the link. For example:Code:td.Connect = "MS Access;Database=C:\MyBackEnd.mdb;"td.RefreshLinkThe RefreshLink command commits the change to the connection string.Reply With Quote:rose::thumbsup:
2 Nov 2012 by abc0077
Hi,Iam generating a Excel file using interop services.I could save the file to my server. When i try to print using the below code it is printed if i run locally.worksheet.PrintOut(Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,...
21 Jul 2014 by Abdallah Al-Dalleh
Hello allFew days ago I deployed an ASP.NET application on the free .NET hosting Somee.com for testing purposes before deploying on paid hosting, but part of my application uses Excel interop using Microsoft.Office.Interop.Excel . The problem is that the web server crashes with the following...
5 Jun 2017 by abdul subhan mohammed
Dear All, I'm creating a windows application in c#, automating MsOffice Excel. i'm trying to hide ribbon display but its not hiding the ribbon. What I have tried: public static bool ChangeRibbonDisplay(IQuestion question, string filename, ShowHide display) { ...
6 Jun 2017 by abdul subhan mohammed
Dear All, I'm creating windows application in c#, where automating MsOffice Excel. I'm trying to get excel application ribbon is currently hide/show. Following code: What I have tried: public static bool EvaluateRibbonDisplay(IQuestion question, string filename, ShowHide display) ...
7 Jun 2017 by abdul subhan mohammed
Dear All, I'm creating a windows application in c# where automating MsOffice Excel. I want to find range of columns was sorted or not. I searched on google but i didn't find any solution, but sorting. What I have tried: Can anyone please help me, how can i find out the range of columns was...
8 Jun 2017 by abdul subhan mohammed
Dear All, I'm creating a windows application in c# where automating MsOffice Excel. I want to change the view type of excel worksheet, programmatically. Click here for more details What I have tried: can any one please help me. Thanks in advance
10 Jul 2017 by abdul subhan mohammed
Dear All, I have created Windows application where automating MsOffice. I have to evaluate inserted sparkline(would like fetch: type, theme, color, etc) in the excel worksheet(already exists). What I have tried: public static bool EvaluateSparkline(IQuestion question, string filename,...
5 Nov 2017 by abdul subhan mohammed
Dear All, I want to export GridView/Repeater to password protected excel file. Currently i'm doing export without password. What I have tried: Response.ClearContent(); Response.AddHeader("content-disposition", "attachment;filename=CandidateList.xls");...
7 May 2018 by abdul subhan mohammed
Dear All, I have an ASP.NET web application in C#. I want to import data from excel to Repeater using linq. The excel file contains company logo(Image), empty rows and multiple table with column names and row names. Example: ...
13 Apr 2013 by Abdulkader_Rai
check your Application Pool -> Advanced Setting -> enable 32 Applications -> True
27 Dec 2014 by Abdullah Al-Muzahid
Hello,I am trying to pass some Table valued parameters to a stored procedure. I created the type like:CREATE TYPE [dbo].[TestTableType] AS TABLE( [Date] [date] NULL, [Ref] [varchar](50) NULL, [Amount] [decimal](20, 4) NULL)GOI passed the parameter to the stored procedure by the...
27 Dec 2014 by Abdullah Al-Muzahid
The problem is solved by passing DataTable to the parameter instead of DataReader.
24 Feb 2015 by Abdulnazark
String.Format("{0:0000}", value);
24 Feb 2015 by Abdulnazark
if my guess correct about your question, it is simple to mapSer.No: =A2 in news sheet and previous posting: =Mid(M2,3,150) in new sheet/range
24 Feb 2015 by Abdulnazark
select case when c4=0 then 'NA'when (D4/C4)=1 then (1-0.0000034226)when (D4>C4) then 'Wrong Data'else(D4/C4) end
25 Feb 2015 by Abdulnazark
you could use Worksheets("Sheet1").Range("A1").Formula = "=Text(value, ""#,##0.000;(#,##0.000);"")"for value = -200000 will be (200,000) format and for colorandif value
2 Mar 2015 by Abdulnazark
see the link & also set EnableEventValidation="false" to the formhttp://www.aspsnippets.com/Articles/Export-GridView-to-Excel-in-ASPNet-with-Formatting-using-C-and-VBNet.aspx
15 Mar 2015 by Abdulnazark
Sub EliminateEndings()Dim i As Long, j As Long, n As LongApplication.ScreenUpdating = Falsen = Cells(Rows.Count, 1).End(xlUp).RowFor i = 2 To n 'assumes headerj = InStr(Cells(i, 1), "(")MsgBox jIf j > 0 Then Cells(i, 1) = Trim(Mid(Cells(i, 1), j + 1, Len(Cells(i, 1)) - (j +...
10 Jul 2013 by abdulsafran
Hi,My problem is I have large amount of data and need a simple VBA to do the below task. If you give me a start then I can do rest of the work. Kindly check and let me know. Your soonest response is highly appreciated.if (B1=B2 && C1=C2 && D1!=D2)...
21 Jun 2011 by Abhi Lahare
Hello Please refer the link http://support.microsoft.com/kb/311546[^]I am assuming that you are not adding interef to Workbooks,Worksheets do include the required header files. HTH
14 Nov 2013 by abhi.crezy
I am creating an Excel Add-Ins for Office 2010. Earlier i was doing code in Visual Studio 2010, .net framework 3.5 on ThisAddIn_Startup likeprivate void ThisAddIn_Startup(object sender, System.EventArgs e){ this.Application = (Excel.Application)Microsoft.Office.Tools.Excel. ...
17 Nov 2013 by abhi.crezy
Unfortunately, you will have to let go of ExcelLocale1033Proxy.Projects that were created by using Microsoft Visual Studio 2005 Tools for the Microsoft Office System instantiate the Excel Microsoft.Office.Interop.Excel.Application object by using the...
4 Dec 2013 by abhi.crezy
I have created an Excel Add-In for office 2003/2007 in Visual studio 2008 with .net framework 3.5. I have used dlls of some other project in my excel add-in project.Due to some reason i have to update dlls in .net framework 4.0.So i need to create Excel Add-In for office 2003/2007 in...
4 Dec 2013 by abhi.crezy
VS2010 vs Excel 2003 add-in[^]Vs2010 is not compatible for office 2003 excel add-in
6 Dec 2013 by abhi.crezy
I have created an excel add-in for office 2007. From code this is working.Now i am creating setup for it.I have set, following settingsFile System -> primary output of ExcelPublisherAddin2007, and all dlls.Registry -> HKEY_Current_User > Software > Microsoft > Office > Excel >...
16 Jun 2017 by Abhi1 Kanobi
Hello Everyone , I am trying to import multiple excel files into sql server through import wizard . The files contain a big list of names and email addresses . The problem after finishing import of one file ( I have created a ID column into destination table , auto increment ) , the rest files...
16 Jun 2017 by Abhi1 Kanobi
A lot of research proved that it's impossible . The excel files need to be restructured to fit the data , and the missing columns need to be added . I was able to insert data .
16 Aug 2014 by Abhijit Ghosh (Subho)
I am trying to parse a string to get something like a formula out of it. My question can be best explained by the following examples:example 1: (12345 in year 1 / 23451 in year 0)-1)*100solution1. (2. /3. )-1)*10012345, 123451, 0example 2: [[1234 in year 1) - (4567 in...
13 May 2013 by Abhijit Jana
This think will help you !Read Data From an Excel File (.xls) in ASP.NET[^]
10 Jul 2015 by Abhik kashyap singh
If this is the case, you should build a loop which loops through the rows in excel data and for each row you assign the values for the command parameters and execute it.In other words if you have 5 rows, you should execute the insert statement five times. Also you would set the values of the...
2 Jan 2014 by Abhilash K M
Private Sub browseXLfile_Click(sender As Object, e As EventArgs) Handles browseXLfile.Click Dim ofd As New OpenFileDialog If ofd.ShowDialog() System.Windows.Forms.DialogResult.OK Then Exit Sub Dim nme As String = ofd.FileName Dim safename As String...
12 Sep 2017 by Abhimaan Sharma
I tried to all the possible solutions, but code is not working. Getting same error again and again. Infact, I've installed the same from below link: https://www.microsoft.com/en-us/download/details.aspx?id=13255 What I have tried: string ExcelContentType = "application/vnd.ms-excel"; ...
20 Mar 2010 by Abhinav S
Maybe this will help you.
25 May 2010 by Abhinav S
If you are interested in having a look at the CLR profiling services rather than the CLR profiler tool - have a look here.
16 Jun 2010 by Abhinav S
No one will send you the code.Have a look here - this[^] may help you.