|
|
Comments and Discussions
|
|
 |

|
Hi,
How to Fill Different Sheets using dataset in same excel File in ASP.Net(C#).
Dataset.tables[0]=sheet(1)
Dataset.tables[1]=sheet(2)
..........
Dataset.tables[n]=sheet(n)
How to handle like this,
Thanks
|
|
|
|

|
Does this method work for web applications or is it just for Windows applications?
I tried a similar method for Word and although it worked fine locally (generated Word documents), it did not work when run remotely, from a workstation (using http://sitename/generateWord.aspx).
|
|
|
|

|
I have an urgent situation that must collect worksheets from multiple xls files and add them to a single workbook. How would one attempt to bring this about using vb.net or c#.net?
Cybertec
|
|
|
|

|
I'm using VS 2005 and I added the "Microsoft Excel 11.0 Object Library" to my project, and I specified "using Excel;", but when I try to compile, I get the error "The type or namespace name 'Excel' could not be found (are you missing a using directive or an assembly reference?)"
I know the page said to use 10.0, but that is not available on the list; only 11.0 and 5.0 are. Does it make a difference that I used 11.0 instead?
What else might be wrong?
Thanks.
-Cat
|
|
|
|

|
I have several Excel spreadsheets which are outputted by SAP that I need to insert into a database. I have been able to do a bulk copy but I have to first edit the spreadsheet to fix errors. The spreadsheets have a date column (set to text format) that have invalid dates (00/00/0000). Can I perform a find and replace on them?
Or is there a way to view the spreadsheet prior to importing into a SQL table in order to fix errors?
Or is there another way to insert Excel spreadsheet into SQL server on a row by row fashion which allows me to fix the errors?
Thanks
Mike
|
|
|
|

|
Him iam unable to compare two excel cell values in c#.net. Also please suggest me how to read null cell value in excel.
please help me .
suresh kumar g
|
|
|
|

|
I'm dealing with many worksheets where I cannot just load "sheet1", because the names have been changed.
I just want to loade the 1st sheet from the workbook, and have had no luck figuring out how to make the missing parameter work.
I'm using C++.net 2005 and have implemented the code from this article, making it all work nicely but cannot, load the worksheet unless I provide the actual name. How do I work around this?
Thanks,
David Sexton
|
|
|
|

|
I want to add a reference for excel to my project, but I didn't succeeded.
I did the instructions step by step and the reference came with yellow triangle of error.
what should I do?
please help me.
|
|
|
|

|
Hi
I am working on a project where i need to copy cells from five different excel files to a new execl file, where the format of the file from where i need to copy is defined, basically the excel files contains charts, i need to copy the specific chart based on some criteria.so if you could please help me out by giving a few lines of code, your help would be appreciated.
Thanks & Regards
-- modified at 6:16 Thursday 22nd February, 2007
|
|
|
|

|
Hi there,
I am creating a web site using C#. I have used your code successfully and I am able to read in the value of the cell A1 and display it in a label. However I want to read in multiple specific columns from my excel document and write them to a SQL database.
How do I pull only certain values from my excel document and in turn write them to a database?
I basically want to add a new record to my database with data from lets say the 1st, 5th and 10th columns in a row. I then want to add another record with the same columns from the next row maybe through some sort of a loop.
Any help would be greatly appreciate!!
Thanks,
Adrian.
-- modified at 7:40 Thursday 15th February, 2007
|
|
|
|

|
I cant seem to get this code to work. When I call the Visible method I get the following error:
System.InvalidCastException occurred.
Query Interface for interface Excel._Application failed.
Any ideas what I am doing wrong?
Thanks
|
|
|
|

|
How do you print an excel table in C#? I was able to generate an excel file, but cant figure out how to print it out using C#. Thanks.
|
|
|
|

|
how to copy a sheet to another new workbook?
|
|
|
|

|
I'm trying to open a spreadsheet invisibly, read some data from it, then
write back to it. The problem is that it it is not coming up editable - it
errors when I try to save the workbook. However, if I open the spreadsheet
visibly, after a number of seconds a dialog pops up "File xxx is now
available for editing. Choose Read-Write to open it for editing", and if you
click the Read-Write button, it works OK.
Here's my code for opening the spreadsheet. The comment is something I found
for the parameters C# needs (since it doesn't handle optional parameters like
VB).
So I'm setting ReadOnly = false, IgnoreReadOnlyRecommended = true, and
Editable = true.
What is wrong? Why does it take the user interaction to open it as
editable/writable? And since it takes up to 12-14 seconds for that Read-Write
dialog to pop up, it's unacceptable.
I also tried entering the parameters exactly like you have it in the article, and I get a dialog "xxx.xls is being modified by . Open as read-only?". This happens whenever I put false in the Notify parameter. But there are no other instances of Excel open on my machine.
Excel.Workbook obWb = obWorkBooks.Open(
filePath,
System.Type.Missing,
bReadOnly,
System.Type.Missing,
System.Type.Missing,
System.Type.Missing,
true,
System.Type.Missing,
System.Type.Missing,
!bReadOnly, // after reading docs I found this parm only applies to earlier versions. Doesn't matter what I have in here, anyway.
System.Type.Missing,
System.Type.Missing,
System.Type.Missing,
System.Type.Missing,
System.Type.Missing);
Scott B
|
|
|
|

|
all,
We are using office automation to convert excel and word to htm we had severa issues like access denied exception etc. and for this issue to solve we followed KB article of MS to configure office under specific user account, but the problem is because security issues we cant follow KB article(http://support.microsoft.com/kb/288367/), by looking at KB article what i felt is they are trying to create a profile for local administrator user. So my question can any body have any alternate for this??
We accept tht we went for bad design, but we dont have any other alternative as this is a must requirement from customer.
Please any cluse any information you have.
And also please note that we are not supposed to set impersonate=true
|
|
|
|

|
Hi All,
I get the following warning during build and am not sure why as i have references to the COM libraries set.Appreciate it if someone could help me out here. I am working on VS 2005 and using Office 2007 PIA's
Warning 1 Ambiguity between method 'Microsoft.Office.Interop.Word._Application.Quit(ref object, ref object, ref object)' and non-method 'Microsoft.Office.Interop.Word.ApplicationEvents4_Event.Quit'. Using method group.
Warning 2 Ambiguity between method 'Microsoft.Office.Interop.Excel._Worksheet.Activate()' and non-method 'Microsoft.Office.Interop.Excel.DocEvents_Event.Activate'. Using method group.
TIA
|
|
|
|
|

|
I have to set color for the font
and background color
alignment
Could you pls help me hoe to set fontcolor,font style and BG color?
|
|
|
|

|
Could you pls help me how can I insert column between the cells .
|
|
|
|

|
I want to save the file without showing the dialogbox yes,no,cancel?
-- modified at 2:10 Saturday 5th August, 2006
|
|
|
|

|
How to read and write the .xls file run at the backgrouund without showing in the screen?
|
|
|
|

|
how to read a particular string from the merge cell ?
And when i open the .xls file EXCEL.exe is opening many times ,could you pls help me how to avoid it?
|
|
|
|

|
I can open the existing .xls file
I can read cell by cell from the .xls file
I can write the cellvalue to the another .xls file
After writing the content how could i quit my application
Kindly review the code pls
private void button1_Click(object sender, System.EventArgs e)
{
//chandroo added
Excel.Application excelApp = new Excel.ApplicationClass(); // Creates a new Excel Application
excelApp.Visible = true; // Makes Excel visible to the user.
// The following line adds a new workbook
//Excel.Workbook newWorkbook = excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
// The following code opens an existing workbook
// Added by Chandroo
// string workbookPath = "c:/Test.xls";// Add your own path here
string workbookPath=txtSource.Text;
Excel.Application oXL;
Excel._Workbook oWB;
Excel._Worksheet oSheet;
Excel.Range oRng;
oXL = new Excel.Application();
oXL.Visible = true;
oWB = (Excel._Workbook)(oXL.Workbooks.Add( Missing.Value ));
oSheet = (Excel._Worksheet)oWB.ActiveSheet;
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(workbookPath, 0,
false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true,
false, 0, true, false, false);
// The following gets the Worksheets collection
Excel.Sheets excelSheets = excelWorkbook.Worksheets;
// The following gets Sheet1 for editing
string currentSheet = "Sheet1";
Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelSheets.get_Item(currentSheet);
// The following gets cell A1 for editing
//Excel.Range excelCell = (Excel.Range)excelWorksheet.get_Range("A1", "A1");
// The following sets cell A1's value to "Hi There"
//excelCell.Value2 = "Hi There";
/* Chandroo
select from worksheet
Excel.Worksheet CurSheet = (Excel.Worksheet)excelSheets.get_Item("Sheet1");
Excel.Range CurCell = (Excel.Range)CurSheet.Application.ActiveWindow.RangeSelection;
string selectedRange = CurCell.get_Address(false, false, Excel.XlReferenceStyle.xlA1, false, CurCell);
MessageBox.Show (selectedRange);
http://www.codeproject.com/csharp/csharp_excel.asp?df=100&forumid=23997&exp=0&fr=26&select=1169000#xx1169000xx*/
int rowCount = 0; // how many rows we parsed
int columnCount = 0;
Excel.Range excelCell = (Excel.Range)excelWorksheet.get_Range("B7", "B7");
excelCell.SpecialCells(Excel.XlCellType.xlCellTypeLastCell,
Excel.XlSpecialCellsValue.xlTextValues).get_Address(false, false,
Excel.XlReferenceStyle.xlA1, false,excelCell);
rowCount = excelWorksheet.UsedRange.Rows.Count;
columnCount = excelWorksheet.UsedRange.Columns.Count;
for(int r = 4; r <= 42; r++)
{
for(int c=2; c < 8; c++)
{
string text = (string) ((Excel.Range)excelWorksheet.Cells[r,c]).Text;
//string text2 = (string) ((Excel.Range)excelWorksheet2.Cells[r,c]).Text;
//m_objRange.set_Value(m_objOpt,"Last Name");
if ( text.Length > 0)
{
oSheet.Cells [r,c]=text.ToString ();
}
}
}
// m_objBook.SaveAs(m_strSampleFolder + "Book1.xls", m_objOpt, m_objOpt,
// m_objOpt, m_objOpt, m_objOpt, Excel.XlSaveAsAccessMode.xlNoChange,
// m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt);
// m_objBook.Close(false, m_objOpt, m_objOpt);
// m_objExcel.Quit();
//oSheet.SaveAs (,);
}
|
|
|
|

|
I can open the existing .xls file
I can read the cellvalue and assign in the string variable
but how can i write the cellvalue in another .xls file which stored in the string variable?
could you pls help me?
|
|
|
|

|
How to read .xls file by giving the cell value and write the cellvalue in another .xls file at the same position using C#.net
Could u pls help me?
chandra999777
|
|
|
|

|
I run this app -- works fine from standalone .exe -- but when I add the code (and references) to my dll in C# it launches EXCEL -- I can see the process -- but the Excel application is not visible -- the process says it is launched by SYSTEM.
Any way to launch from my DLL?
|
|
|
|

|
This was very helpful for a little app I had to write that interfaced with Excel. Isn't it great how something from three years ago is still helpful?
Marc
Pensieve
Some people believe what the bible says. Literally. At least [with Wikipedia] you have the chance to correct the wiki -- Jörgen Sigvardsson
|
|
|
|

|
Hi,
I created an application using Excel 2003 on my pc, so it uses the object library version 11. The target for my application are PC's with Excel 2003 and Excel 2000. The problem is that on the PC's with 2003 it all works fine, but on the PC's with Excel 2000 exceptions are thrown.
Is there any way to make to calls to Excel compatible between these versions or how can I build my applications so it supports both versions?
thanks,
Sander
|
|
|
|

|
Hello,Every one!
You can try to use the professional .net data export component for excel.
It supports MS Excel , MS Word, HTML , XML , PDF , MS Access ,DBF, SQL Script, SYLK,DIF,CSV ,MS Clipboard format.
Visited: http:\\www.e-iceblue.com
|
|
|
|

|
Great work.
But I tried to use them with Excel Object 11.0 and Visual Studio 2000 J#, the ".get_Workbooks().Open()" method doesn't work. It does work with Studio 2000 C#.
Any idea? Thanks.
|
|
|
|

|
Hello,
I am using VS 2005 to develop my Web Application. I have added the COM reference through the IDE and my page works fine on the localmachine. ie http://localhost/excelTest.aspx loads fine and creates my Excel document.
The problem is that when I publish the site to my testing server via the "Copy Website" feature to the "Remote Site", the reference is lost while the libraries are transferred.
Error :
The type or namespace name 'Excel' could not be found (are you missing a using directive or an assembly reference?)
Statement :
<%@ import Namespace="Excel" %>
Is there some form of pragma statement or something I can use to make the library available. I'm new to .NET and C#, I know how VC++ ammends the build file to include the reference but can't see where the reference is recorded.
Quite clearly adding the reference does more than simply add the DLL files the the BIN directory - I've created the site by adding the reference and by not, both sites have identical files but don't work the same.
Any help on this would be greatly appreciated.
Thanks,
Damian Del Campo
|
|
|
|

|
I use the following code to open excel and get the sheetname, then use oledb to read the excel doc - which works great with C#. unfortunately I want to delete the file when I'm done reading it and i get a sharing violation. Even after my app closes there is an instance of excel.exe running still in spite of me calling quit() etc. what can I do to solve this!
Excel.Application ExcelObj = null;
ExcelObj = new Excel.ApplicationClass();
if (ExcelObj == null) {
System.Windows.Forms.MessageBox.Show("ERROR: creating excel object");
return false;
}
Excel.Workbook theWorkbook = ExcelObj.Workbooks.Open(aFileName,
0, true, 5, "", "", true, Excel.XlPlatform.xlWindows,
"\t", false, false, 0, false, null, null);
// need to know the worksheet name
Excel.Worksheet mySheet = (Excel.Worksheet)theWorkbook.Sheets[1];
string SheetNamestr = mySheet.Name;
ExcelObj.Quit();
|
|
|
|

|
Hi!
I want to display the excel sheets in a dropdownlistbox in asp.net application with c#.
I am getting an error saying "access denied".
Can u pls advise what to do with to solve this error???
I am having .Net framework1.1, MS Excel 2000 and XP operating system.
My source code:
using Excel;
using System.Runtime.InteropServices;
public string sFileName;
public Excel.Application oXL;
public Excel.Workbook oWB;
public Excel.Worksheet osheet;
public Excel.Range oRange;
public string sRange;
sFileName = "C:\\Project\\Temp\\ExcelExport\\SData.xls";
ListItemCollection ListSheets = new ListItemCollection();
oXL = new Excel.Application();
oWB = oXL.Workbooks.Open(sFileName, 0, true, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true);
foreach (Excel.Worksheet sheet in oWB.Sheets)
{
sRange = sheet.UsedRange.Rows.Count.ToString();
ListSheets.Add(new ListItem(sheet.Name,sRange));
}
ddlSheets.DataSource = ListSheets;
ddlSheets.DataTextField = "Text";
ddlSheets.DataValueField = "Value";
ddlSheets.DataBind();
Please help me !! Your solution would be of immense help to me!!!!!
THANKS A LOT !
Yukta!
|
|
|
|

|
Hello Everyone,
When I use an ODBCDataReader to read data into a datatable I have an issue with certain cells. If I have a cell with 00000 in it, and its specified as a text column, the driver returns an empty string, any idea's?
Thanks,
Ryan
-- modified at 13:51 Monday 27th February, 2006
|
|
|
|

|
Is it possible to make a cell readonly? so that users cant update the uploaded content of that cell.
Deepak
|
|
|
|

|
Hello,
I wrote a small app in C# which opens a tab delimited file using the OpenText command. This works well on Excel 2000 but if I try it on Excel 2003 I get an Exception. Any reason why this should happen?
Sunil
|
|
|
|

|
Have you tried to create a web service for printing XLS files? I have been able to do this using Word. However, for Excel, there are no printers defined.
|
|
|
|

|
Hello,
I'm trying to open a tab separated file in an Excel file using the Excel API in my code. I note that there is a OpenText method, but am not sure about all the parameters. Does anybody know how to use this function?
Sunil
|
|
|
|

|
Hello,
Does anyone know of a good reference manual for the Excel Object?
Rather than googling all over the net trying to find the methods of an object, I'd like to find a comprehensive "programming guide" preferably in C#.
Thx.
Andy Jacobs
|
|
|
|

|
What is the use of SpecialCells and how to use it.
Thanks
Tush
|
|
|
|

|
My Excel looks like this
Blank Row
Blank Row
Sr No Name
1 Tush
2 Jeff
3 Suzan
4 Sam
I have used trowCount= targetworksheet.UsedRange.Rows.Count;
It gives count as 5 where as i want 7
Please help me out
and is there any "end of file" property
Please give me a solution
Thanks
Tush
|
|
|
|

|
hi, can you help me pls,
I am traing to write a C# program that opens an excel page and then it puts a value in a some cell. I used the program on this page but it writes me a mistake " Old format or invalid type library" , can u explaine me what is the corect way? hlp with the code?
Thanks'
|
|
|
|

|
I could able to read data for given range.But I want to read data from only selected range or rows from spreadsheet
suppose code is like this :
Excel.Range excelCell =
(Excel.Range)excelWorksheet.get_Range("A1", "A1");
in get_Range() function , I don't want to give any default range like (a1:a3) or (a3:a7).
This range may vary depending upon user's selection. I'm not able to trap that dynamically selected range values.
|
|
|
|

|
I want to automate an Excel97 application using C#. I use the excel8.olb
file as COM interface. How can I check the country code of the installed
Excel application? I know that there is a method
"LanguageSettings.get_LanguageID()", but it works with Excel XP.
regards
|
|
|
|

|
Hi,
First of all I'd like to say that you've done a good job with this article.Congrats!
I wrote an app to export some custom data to Excel and I have a small but annoying problem. The security policy of the network I'm testing within is not allowing Excel to be started from my app.
WOuld you have any solution on how to solve this from my program, I mean creating an over all portable application ?
Thanks.
Angel
|
|
|
|

|
Hi, I'm trying to create a reference to the Excel 10 Object Library but I can't find it in the reference list. I have Office XP installed so it should be there? Any ideas?
|
|
|
|

|
How can I read data from Excel using C#? I am able to use get_range function to read data from a cell, However, I do not know the number of columns and rows in an Excel worksheet and without knowing the number of columns and rows, I can not read data from the whole worksheet.
|
|
|
|

|
Hello,
I've got a problem with access to special ranges. I renamed some cells (for example "C4" in "CUSTOM.GENERAL.VPRIM"). This is necessary, because I have to read out only these cells in active worksheet. The method get_range("RangeName", Missing.Value) is ok as far as I have an existing RangeName.
My program compares the root of a customized XML file with the range of an Excel file. But some root names don't exist in the Excel file. If I deliver a wrong RangeName to the get_range() Method I get an Exception. So, I have to check the existance of a RangeName at first.
Can anybody help me? I've searched for 3 days in all forums without luck.
Many Thanks - Maik
|
|
|
|

|
hi,
i used the same code to create an excel file from .cs(console application) and aspx.cs (web application) .
But there is a "Server Eexcution failed" error when i reach the following statement in web application.
this.objApp = new Excel.ApplicationClass();
can anyone help me how to resolve it?
thks,
|
|
|
|

|
Hi,
My excel sheet looks something like
Item1 Item2 Item3
1 2.2$ 2.2$ 3.4$
2 1.9$ 3.2$
3 6.2$
and so on..
How can I set/get a cell at position [Item1,3] ???? I dont want to access it as actual cell number of excel sheet like A1 etc
THanks
|
|
|
|

|
.Net programmer in C# trying to change the format of an Excel collumn to Text.
This makes the data in column D display in cash format whenever new data is entered in col D (oRng is the Excel.Range object, oSheet):
oRng = (Excel.Range)oSheet.Columns["D",Type.Missing];
oRng.NumberFormat = "$0.00";
How do I make column E always display as text format? The problem is that some of the data has leading 0's and I need them preserved.
Thanks,
Heri
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
Introduction to manipulating Excel with C#.
| Type | Article |
| Licence | CPOL |
| First Posted | 2 Oct 2003 |
| Views | 968,043 |
| Downloads | 13,909 |
| Bookmarked | 219 times |
|
|