从Crystal Report导出的EXCEL文件导入数据 [英] Importing Data From EXCEL File Exported By Crystal Report
问题描述
Hey Guys,
我的情况非常严重,
我的客户给了我某些数据的excel文件。
excel文件从另一个我没有的应用程序的Crystal Report导出
自动化进行编辑。
他希望我在我的网站上添加一个页面,可以上传并将这些数据插入我的网站
因为可能有其他Excel文件要上传和插入。
我已经尝试了很多找到一些方法来获取该excel文件中的数据,但我遇到了这些问题:
1- excel文件中的列以某种方式进行交互不知道。
2- excel文件中有一个包含无用数据的标题。
所以我希望任何人有想法这样做。
我已经为Excel文件准备了一个模板文件(数据开始来自第15行)
Hey Guys,
i''ve a serious situation,
My Client gives me an excel file for some data.
The excel file is exported from Crystal Report of another application that i don''t have
autorization to edit in it.
He wants me to add a page to my website that could upload and insert these data to my website
because there might be another Excel files to upload and insert.
I''ve tried alot to find some way to get data in that excel file but i''ve faced these problems:
1- The Columns in the excel file are interacted in some studpid way i don''t know it.
2- There is a header in the excel file that contains useless data.
So i wish if any one have an ideas to do that.
I''ve prepared a template file to the Excel file (data starts from row no. 15)
Col14 Col13 Col12 Col11 Col10 Col9 Col8 Col7 Col6 Col5 Col4 Col3 Col2 Col1
98 0 0 0 0 655 Name 1 123
987 0 0 0 0 asd 654 Name 2 234
987987 0 0 0 0 zxc 897 الهند Name 3 45
999 0 0 0 0 aqwe 888 مصر Name 4 645
8741 0 0 0 0 vdfg 6555 الاردن Name 5 76
是Mediafire上的链接
先谢谢
HERE is the Link on Mediafire
Thanks in Advance
推荐答案
尝试下面的代码...
在下面的代码中,你将读取Excel数据并可以使用insert Datatable或者你可以使用如下所示的显示... 。
Try below code...
In below code, u will read Excel data and can use insert Datatable or u can use as show in below....
Select the ACCESSExcel Table INTO an Excel Spreadsheet
try
{
//SELECT INTO command
string cnStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + AccfilePath +
";Persist Security Info=False";
ConnOpen(cnStr);
using (connectionToDatabase)
{
//Give the Export Table (destination) a Name
//baseTblName = dt.TableName;
//Generate the SQL string to SELECT * INTO the NEW table in destination
string selectcmd = "SELECT * " +
"FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0'," +
"'Excel 12.0;Database=" + EXCELfilpath + ";IMEX=1'," +
"'SELECT * FROM ["+sheetName+"
')跨度>;
使用(OleDbCommand createCmd = new OleDbCommand(selectcmd,connectionToDatabase))
{
createCmd.ExecuteNonQuery();
}
ConnClose();
}
}
')"; using (OleDbCommand createCmd = new OleDbCommand(selectcmd, connectionToDatabase)) { createCmd.ExecuteNonQuery(); } ConnClose(); } }
谢谢伙计我已经解决了我的自我
我已说服我的客户将数据放入某种模板文件中
thanks Guys i''ve solved it my self
i''ve convinced my client to put the data in some kind of a template file
这篇关于从Crystal Report导出的EXCEL文件导入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!