从Excel工作表读取格式化的数据,然后保存在数据库中. [英] Read formatted data from excel sheet and save in database.

查看:76
本文介绍了从Excel工作表读取格式化的数据,然后保存在数据库中.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我已经在我的应用程序中实现了从excel功能导入.

我需要将格式化的数据从excel列保存到数据库中.
例如,列值包含的字符串为格式化的字符串在此处."

然后将其按格式保存在数据库中.

我正在读取Excel工作表中的列作为

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

foreach (DataRow row in dt.Rows)
           {
               excelSheets[i] = row["TABLE_NAME"].ToString();
               i++;
           }





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



并将OleDbConnections的值设置为字符串



and set value of OleDbConnections in string as

string str_value=Obj_OleDbConnection[0];


并将此str_value插入到databse中.

请建议我如何在与Excel工作表相同格式的数据库中插入记录.

在此先感谢


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

推荐答案

数据库不存储诸如Font,fontweight等信息,它们仅存储字符串的值.如果要保留此类项目,则需要在数据库中创建类似这样的表

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

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


这篇关于从Excel工作表读取格式化的数据,然后保存在数据库中.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆