Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

I created web application, in this application there is a part of insert byte[] (image byte[] value) in to excel sheet using DataTable (Its having Byte[] Value). so can any one suggest me how to insert or store the DataTable Byte[] value into Excel sheet.


Thanks in Advance,
Mohan G
Posted

1 solution

You cannot store binary array values direclty in Excel. You have to convert them to the format acceptable by Excel. Encode array values as base-64 string. Then you can store it in Excel cell.
 
Share this answer
 
Comments
Mohan Gopi 22-Dec-13 0:47am    
Hi Adam,
Thanks for your reply, i will try according to your suggestion.
Adam Zgagacz 22-Dec-13 7:18am    
I'm glad I could help.
Mohan Gopi 28-Dec-13 1:57am    
Hi Adam,

Thanks for your reply. i converted image to base-string64 (converted string having more than 10000 Characters). After that i am try to insert this string(Large 10000 characters) into Excel sheet that time i am getting "The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data." this Error. So please suggest me to solve this problem.

Thanks in Advance,
Mohan G
Adam Zgagacz 30-Dec-13 9:12am    
Well, if you really need to store binary data in Excel (it's a little bit abusing of Excel. Excel wasn't created for binary data storage) you need to:
1. Convert binary data to text (you are already doing it by base-64 encoding)
2. Split text into smaller chunks and store each piece in separate cell. This way one image would be stored in several cells.

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