 |
|
 |
Many Thanks for the wonderful code,
But how do i add headers in the excel file, using your code. It will be really greatful if you provide a solution to it.
|
|
|
|
 |
|
 |
Here is the code to add headers to the excel document.
for (int q = 1; q <= dt.Columns.Count; q++)
{
((Microsoft.Office.Interop.Excel.Range)sheet.Cells[4, q]).Value2 = dt.Columns[q-1].ColumnName.ToString();
((Microsoft.Office.Interop.Excel.Range)sheet.Cells[4, q]).Font.Bold = true;
}
Just iterate through DataTable Columns and get column names
|
|
|
|
 |
|
|
 |
|
 |
Fernando, a mi me pasa lo mismo con un proyecto en vs2005
en una opcion que me permitia pasar el contenido de una grilla
a una hoja de excel
este error me sale si es que hago click en la hoja de excel miestras se esta llenando
sin hacer click , no aparece ningun error.
ahora estoy buscando como evitar este error
apenas tenga novedades te aviso
Saludos
Claudio
ghgh
|
|
|
|
 |
|
 |
This code works but so slow.
-----------------
Serdar YILMAZ
Senior Developer
|
|
|
|
 |
|
 |
Hi,
I was playing around with this code and for some reason Excel.Application newXCl = new Excel.Application() triggers an exception for me. I was wondering if anybody knows what the reason might be
|
|
|
|
 |
|
 |
Hi
first of all thank you for the code, helped a lot.
i would like to know how i can format cells:
- give them a special font
- make the size of the colume to auto fit the data in it
- save the file created directly from the code and give it a name.
i don't know if it's possible to do that but i tried some of the options given like autofit() and .Font but nothing worked.
If you could please help as you look like you handled well the excel
|
|
|
|
 |
|
 |
Hello,
I'm trying to run your code under .Net 2003, but I'm unable to find the Excel.dll on the COM tab.
I'm wondering if the way of creating Excel sheet changed since 2002 ?
I added all COM linked to excel but the soft doesn't recognize Excel....
Could you help to figure out what's my problem ?
Thanks for your help,
Seb
|
|
|
|
 |
|
 |
Sorry that's ok after searching on MSDN, I found the correct COM.
the strange thing is that now I have to type Microsoft.office.interop.Excel instead of just Excel.
But it's probably due to the fact I'm beginner... sorry for that.
Thanks
|
|
|
|
 |
|
 |
hi i am running into the smae problem but i cant find that dll on my computer, or from MSDN. can u help?
|
|
|
|
 |
|
 |
Hi
I need help in embeding the sql queries in excel sheet so that every time i open the excel sheet my data automatically gets updated from database. I have recorded a macro in excel sheet but finding it difficult to write same in C#.
In my application i've retrived some data from the DB & displayed them in the Datagrid. Now if click export to excel the data ehat ever show in datagrid will be exported and I have to embed the corresponding SQL query in the excel sheet. This makes my data in excel updated automatically while opening.
I've recorded a macro from excel & want to do the same programatically from C# application
Any help will appreciated .
============================================
Sub Macro1()
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DRIVER=SQL Server;SERVER=Local;UID=;APP=Microsoft® Query;WSID=WEST;DATABASE=NorthWind;Trusted_Connection=Yes" _
, Destination:=Range("C4"))
.CommandText = Array("exec GetAllCustomers")
.Name = "Query from NorthWind"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = True
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=True
End With
End Sub
==========================================
Thanks in advance
~Senthil
|
|
|
|
 |
|
 |
this is very useful code but needs some touch...thank you for the codebut still needs some touch you can see it below..it works perfect..
for(int i = 1 ; i <= dt.Rows.Count ; i++)
{
for(int j = 1 ; j <= dt.Columns.Count ; j++ )
{ ((Excel.Range)sheet.Cells[i,j]). Value2 = dt.Rows[i-1].ItemArray[j-1].ToString();
}
|
|
|
|
 |
|
 |
Hai dude,
Thanks,I modified that just now before.
|
|
|
|
 |
|
 |
i checked it ...for small database works fine but for the big one doesnt work at all...
|
|
|
|
 |
|
 |
Hai dude,
I have used this application in big Data base also... I dont know where you got error.. If you tell me , I can check and tell the solution.Thanks
|
|
|
|
 |
|
 |
when i run program for a database table has 7-8 rows works fine...but for big tables for example table has 5000 rows , all i got is empty excel sheet after proccess...thanx
|
|
|
|
 |
|
 |
Hai dude,
I modified the Code... Now it ll work proper... check it out. I am really sorry for the bug....Thanks
|
|
|
|
 |
|
 |
The size of the demo is toooo big for me. So I didn't download it. What's in it?
Work hard, Work effectively.
|
|
|
|
 |
|
 |
hi,
That zip file contains the complete application.Its very small application. And i have attached all the code in the description part itself. So you can try it using that code.
|
|
|
|
 |
|
 |
I have convert database records to excell file in web application how it is possible.
|
|
|
|
 |
|
 |
Hai dude,
I am also trying the same thing... For that the web application ll try to access the com object. So the user should have rights to access that.. Other wise it ll give error like... Check username and passs ... etc.. .
So I am also waiting to get a solution. If you find anything.. please tell me too...
|
|
|
|
 |
|
 |
Wat is that ctl_progress.. Its throwing an error for me in web application..
And moreover that variable is not defined in the tutorial also
satheesh kumar kk
|
|
|
|
 |