 |
|
|
 |
|
 |
Can you pls tell the same(sample code) for Datagrid jsp data export to Excel and pdf.??
|
|
|
|
 |
|
|
 |
|
 |
Well, i don't thinks it's legal to provide the Excel and Word libraries in a comercial application.
If i use the installed excel version as reference library, i'm not sure if the installed library is compatible with the source code of the ExportToExcel class... and i need excel to be installed.
Isn't there a way to make Excel export from DatagridView possible without use of any office library?
|
|
|
|
 |
|
 |
If you want to read, write excel , with out Ms-Office installed on the server, then you can try to use a c# excel component name Spire.XLS,may help to you.
|
|
|
|
 |
|
 |
Hi,
it is possible to export DataGridView to Excel without Excel Interop with this Excel C# / VB.NET component.
Here is a sample Excel C# code how to use it in Windows Forms app:
var bindingSource = (BindingSource)this.peopleDataGridView.DataSource;
var dataTable = ((DataView)bindingSource.List).Table;
var ef = new ExcelFile();
ef.Worksheets.Add(dataTable.TableName).InsertDataTable(dataTable, 0, 0, true);
ef.SaveXls(dataTable.TableName + ".xls");
|
|
|
|
 |
|
 |
When executing function
Exc.Workbooks.OpenText(pFileName, Missing.Value, 1,
XlTextParsingType.xlDelimited,
XlTextQualifier.xlTextQualifierNone,
Missing.Value, Missing.Value,
Missing.Value, true,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value);
Gives this error: AccessViolationException, bad memory, or damaged memory.
Do you know how to solve this issue ?
|
|
|
|
 |
|
 |
when the switch to unicode(UT-8) font fail
|
|
|
|
 |
|
 |
I had downloaded your Project and run it. It worked well.
But I'm using C# 2005 and MS Office 2003. How can I do this work?
Plz help me! Thanks alot!
|
|
|
|
 |
|
 |
Interop has problems when dealing with differnet versions of Microsoft Excel. If you have such problems try using 3rd party .net components for excel. For VS2005, i don't think you will have problems beacause of that.
|
|
|
|
 |
|
 |
First, thank you very much for this great tool! It seems to work well, except that in my case I end up with an empty excel file . I'm using VS 2008, .Net 3.5 and Office 2007. Any help would be greatly appreciated!
Cheers
J
|
|
|
|
 |
|
 |
hI, well i never test my code on 2008, but i think it should work well.
What data type are you trying to export?
Ok, can you make a test? first try to export a datatable and later the datagridview or arraylist.
Maybe the reason is the Office Interop Assemblies in my project was for Office 2003, try this instead
http://www.microsoft.com/downloads/details.aspx?familyid=59DAEBAA-BED4-4282-A28C-B864D8BFA513&displaylang=en
Greetings
|
|
|
|
 |
|
 |
I tried installing the updated PIAs, but I think I already had them installed. Your sample application works fine. The datatypes I'm exporting are only string and int. I'll try a couple more things and let you know. Thanks again for the tool and your help! Especially the quick reply.
Cheers
|
|
|
|
 |
|
 |
Ok, I'm using a BindingSource for DataSource of my DataGridView, so it falls out of the swtich block. Not sure how to get the data from BindingSource into DataTable. Any suggestions?
|
|
|
|
 |
|
 |
use these code
else if (dataGridView.DataSource is BindingSource)
{
BindingSource bs=(dataGridView.DataSource as BindingSource);
DataSet ds=(bs.DataSource as DataSet);
dt = ds.Tables[bs.DataMember];
}
|
|
|
|
 |
|
 |
I just download zip and tryed start, i had error
System.Runtime.InteropServices.COMException was unhandled
Message="Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154."
i tryed to registate dll, same error
|
|
|
|
 |
|
 |
You need yo have Microsoft Office Xp to run this code
|
|
|
|
 |
|
 |
I can't dowload this file.. so i need it. Please check again.Thanks You!
|
|
|
|
 |
|
 |
Hmmm... the file is ok, maybe is you connection (firewall, proxy, nat...), note that is a .zip file with binary .exe files inside, several proxy may filter this kind of file
Kev
|
|
|
|
 |
|
 |
I've created a datatable using unicode UTF-8, but when i export to excel file, all text went wrong format. I ca'nt read them anymore. Could you help me? i'm in hurry :(
|
|
|
|
 |
|
 |
this is good work men.
but can i get vb version of this ?
converting to vb i got error
at sb = sb + (If(Information.IsDBNull(dr(i)), String.Empty, FormatCell(dr(i)))) + ControlChars.Tab
Error: expected expression
thanks
|
|
|
|
 |
|
 |
You can use something like this
Dim sb As String
If Information.IsDBNull(dr[i]) Then
sb = String.Empty + ControlChars.Tab
Else
sb = sb + FormatCell(dr[i]) + ControlChars.Tab
End If
Tell me if things goes wrong
|
|
|
|
 |
|
 |
I post later the vb code from this c# code
|
|
|
|
 |
|
 |
Your code is Great! But in my case I've made an 8 column datagridview: The first 4 columns are retrieved from a datatable and the last ones are created manually. So when I cast the datagridsource to a datatable that I've created like you did I only receive the first 4 columns. Please Help me.
|
|
|
|
 |
|
 |
Well, my code is intended to export data from a datagridview through it's datasource as a datatable. I can't figure out a way to do directly from datagridview directly cause datagridview can contain such many things, images, binary data, and lots of other things, i can suggest you try to create a datatable manually with appropiate columns and populate them.
Post me your code and maybe i can try to help you.
|
|
|
|
 |