PDA

View Full Version : انتقال طلاعات از فایل EXcel به جداول بانک اطلاعاتی



amin3271
چهارشنبه 29 آبان 1387, 13:19 عصر
سلام
چطور می تونم از یک فایل excel اطلاعات را خوانده و درون جدول متناظر آن در بانک اطلاعاتی SQL server بریزم

Afshin160
چهارشنبه 29 آبان 1387, 13:34 عصر
با سلام ...
دوست عزيز ميتوني به فايل excel يه كانكشن بزني و از اونجا بخوني و توي sql بريزي .


http://www.connectionstrings.com/images/icons/excel2007.gif Excel 2007This is a compiled connection strings reference list on how to connect to Excel 2007.ACE OLEDB 12.0Xlsx filesThis one is for connecting to Excel 2007 files with the Xlsx file extension. That is the Office Open XML format with macros disabled.Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties="Excel 12.0 Xml;HDR=YES";
"HDR=Yes;" indicates that the first row contains columnnames, not data. "HDR=No;" indicates the opposite. http://www.connectionstrings.com/images/icons/copytoclipboard.gif COPY TO CLIPBOARD (http://javascript<b></b>:CopyConnectionStringToClipboard(document.getEleme ntById('p0cs0cell'));)Treating data as textUse this one when you want to treat all data in the file as text, overriding Excels column type "General" to guess what type of data is in the column.Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties="Excel 12.0 Xml;HDR=YES;IMEX=1";
If you want to read the column headers into the result set (using HDR=NO even though there is a header) and the column data is numeric, use IMEX=1 to avoid crash. To always use IMEX=1 is a safer way to retrieve data for mixed data columns. Consider the scenario that one Excel file might work fine cause that file's data causes the driver to guess one data type while another file, containing other data, causes the driver to guess another data type. This can cause your app to crash. http://www.connectionstrings.com/images/icons/copytoclipboard.gif COPY TO CLIPBOARD (http://javascript<b></b>:CopyConnectionStringToClipboard(document.getEleme ntById('p0cs1cell'));)Xlsb filesThis one is for connecting to Excel 2007 files with the Xlsb file extension. That is the Office Open XML format saved in a binary format. I e the structure is similar but it's not saved in a text readable format as the Xlsx files and can improve performance if the file contains a lot of data.Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myBinaryExcel2007file.xlsb;Exte nded Properties="Excel 12.0;HDR=YES";
"HDR=Yes;" indicates that the first row contains columnnames, not data. "HDR=No;" indicates the opposite. http://www.connectionstrings.com/images/icons/copytoclipboard.gif COPY TO CLIPBOARD (http://javascript<b></b>:CopyConnectionStringToClipboard(document.getEleme ntById('p0cs2cell'));)Xlsm filesThis one is for connecting to Excel 2007 files with the Xlsm file extension. That is the Office Open XML format with macros enabled.Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsm;Extended Properties="Excel 12.0 Macro;HDR=YES";
Important note!
The quota " in the string needs to be escaped using your language specific escape syntax.
c#, c++ \"
VB6, VBScript ""
xml (web.config etc) &quot;
or maybe use a single quota '. "HDR=Yes;" indicates that the first row contains columnnames, not data. "HDR=No;" indicates the opposite. http://www.connectionstrings.com/images/icons/copytoclipboard.gif COPY TO CLIPBOARD (http://javascript<b></b>:CopyConnectionStringToClipboard(document.getEleme ntById('p0cs3cell'));)

برو به اين لينك :
http://www.connectionstrings.com/?carrier=excel2007

موفق باشيد
افشين160

Alen
چهارشنبه 29 آبان 1387, 17:38 عصر
سلام از openrowset هم میتونی استفاده کنی
این لینک رو ببین
http://support.microsoft.com/kb/306397