Click here to Skip to main content
15,936,517 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello ,

I have implemented import from excel functionality in my application.

My need is to save formatted data from excel column into database.
Ex it the column value contains string as "formatted String is here. "

Then is saves in database as it is with formatting.

I am reading columns from excel sheet as
C#
foreach (DataRow row in dt.Rows)
           {
               excelSheets[i] = row["TABLE_NAME"].ToString();
               i++;
           }


C#
if (excelSheets.Length > 0)
           {
               command.CommandText = "SELECT * FROM [" + Convert.ToString(excelSheets[0]) + "]";
               command.Connection = Obj_OleDbConnection;
           }


and set value of OleDbConnections in string as
string str_value=Obj_OleDbConnection[0];

and insert this str_value in databse.

Please suggest me how can i insert record in database same formatted as in excel sheet.

Thanks in advance
Posted
Updated 7-Jul-11 22:08pm
v2
Comments
mostafa_darwiche 8-Jul-11 4:15am    
hello,

did you know the types of the data before extract it from excel?

1 solution

Databases do not store such information as Font, fontweight etc, they just store the value of the string. If you want to persist such items, then you need to create tables in your database something like this

SQL
Table Values
valueID (int)
value (varChar(45))
valueFontID (int)
valueFontWeightID (int)
valueFontSize (int)

  Table ValueFonts
FontID
FontName

  Table FontWeights
FontWeightID (int)
FontWeightStyle (int)



Hope this helps
 
Share this answer
 
v2

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