Tag Archives: c++

C# how to iterate over excel columns

Questions: I want to get a specific column of an excel sheet and then iterate through it’s cells. I want it to look something like this: Excel.Workbook workbook = app.Workbooks.Open(svDropPath); Excel.Worksheet xlWorkSheet = (Excel.Worksheet)workbook.Sheets[“Sheet Name”]; var col = xlWorkSheet.UsedRange.Columns[“C:C”, Type.Missing]; // I want the 3rd column foreach(Cell c in col) …. How do I actually… Read More »

Query excel sheet in c#

Questions: I want to read Excel file in c# using following code string excelFileName = “Book2.xls”; string excelConnectString = @”Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Book2.xls;Extended Properties=””Excel 8.0;HDR=YES;”””; //string excelConnectString = @”Provider = Microsoft.Jet.OLEDB.4.0;Data Source = ” + excelFileName + “;” + “Extended Properties = Excel 8.0; HDR=Yes;IMEX=1”; OleDbConnection objConn = new OleDbConnection(excelConnectString); OleDbCommand objCmd = new OleDbCommand(“Select *… Read More »

Center Excel Cell Content using Excel Interop w/ C#

Questions: I am trying to center the values of the cells that will be used as headers. This is the code I am currently using to format these cells already. I am using the Excel Interop with C#. How do I center the values in this range of cells. public void createHeaders(int row, int col,… Read More »

How can i write to an excel using Microsoft.Office.Interop.Excel.Application in c# [closed]

Questions: I would like to have a simple example to write to an Excel spreadsheet using the Microsoft.Office.Interop.Excel.Application objects in c# Any one please help Thanks Answers: Interop is not supported in server scenarios (like ASP.NET) according to MS. There are many options to read/edit/create Excel files without Interop/installing Excel on the server: MS provides… Read More »

Non-commercial C# Library to format Excel? [closed]

Questions: I have a list of reports that are exported to excel through some reporting services, and on my server i need to loop through these spreadsheets and perform additional formatting e.g. 1) hide columns 2) rename sheets 3) freeze panes 4) set default zoom, print size, etc. 5) save as html or convert to… Read More »

Programming MS office with C# – is it possible?

Questions: MS office apps like Excel can be programmed with Visual Basic for Applications.Is it possible to program MS office with C# for advanced tasks? Answers: Yes, it is. You can use Visual Studio Tools for Office, which allows add-ins to be written in C#, VB.NET, etc. It uses COM interop to communicate with Office.… Read More »

To read/write from excel spreadsheet using C#

Questions: I need to make a program that writes some data to an excel spreadsheet. Something basic along the lines of First name, last name, phone number, e-mail per row with each category in its own column. I don’t even know where to start. If someone could tell me which assemblies to reference and maybe… Read More »

Read and Write Excel Files C#

Questions: Is there any easy to implement library that can be used to read excel files and may be create them later on? is this my best bet? http://support.microsoft.com/kb/302084 Answers: If you are willing to commit yourself to a later version of Excel (2007+) you can also take a look at the OpenXML SDK. It’s… Read More »