Click here to Skip to main content
15,908,842 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all experts,
I created MVC application to make one report and i want to export all data from my datatable to excel. I try to use 2 ways already to export.
1. using Javascript
2. using Respone.write(....)
but both ways are incorrect because of my item structure is started from 0 ( ex: 00000189361 ).
when i used those way, in item code col in excel will remove all 0 in front of my item (ex 00000189361 will go to 189361 in excel).
I think that if i use Excel Reference, maybe i can format it to Text.

Does anybody know how to export to excel using COM or Excel Reference?

Thanks

TONY
Posted
Comments
Pheonyx 27-Oct-13 12:13pm    
From what I've been told in the past, using the Excel Interop is bad practice for a web server as it requires excel to be installed on it. There are various tools out there that might help you, try looking at NPOI or EPPlus, they are pretty good at producing formatted Excel documents either XLS or XLSX (depending on the one you choose). If you are exporting values such as 0000000154534 it is advised to wrap quotes around them so that Excel treats them as text rather than numbers.
soeun tony 27-Oct-13 21:26pm    
Hi Pheonyx,
As you said "it is advised to wrap quotes around them". I tried to input ' in front of item code and when export, it display '00000189361.
Thanks
TONY
thatraja 28-Oct-13 9:58am    
So the issue solved?
soeun tony 28-Oct-13 22:06pm    
The issue not yet solved because the item code remove 0 and if i use ', the item code will display this sign ' in front of item code.

thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900