我现在在给给公司做的应用系统中实际遇到的情况!
需要把大量的EXCEL数据倒入到SQL SERVER 2000中(系统用的数据库),请问是否有这方面现成的控件或者有这方面的实现方法!请告诉我高分相送,实际开发用的请写的详细点或者告诉我详细资料的地址!谢谢!
需要把大量的EXCEL数据倒入到SQL SERVER 2000中(系统用的数据库),请问是否有这方面现成的控件或者有这方面的实现方法!请告诉我高分相送,实际开发用的请写的详细点或者告诉我详细资料的地址!谢谢!
解决方案 »
- 新手要做B/S结构的管理系统,请大家给点建议
- 用delphi开发asp组件的问题
- SQL命令超过255个字符怎么半?
- 请帮我将给出灰度指纹图转成二值图的算法。正文件中有样图
- cxgrid的多选记录 修改记录问题??
- PANEL1有两个事件ONCLICK和MOUSEDOWN,问题不难
- 在哪里可以下到DELPHI 1 -- 5啊?谢谢各位了
- 请问怎样获得dbgrid的某个字段名?
- 只有27分了,你们帮帮小弟吧.
- 如何在richedit中显示big5和日文字?望赐教!
- 又一个弱智的人,快来抢分!唉!
- ******非常急!我想在DELPHI中用程序实现控制SQL SERVER 2000但不知道怎么实现,在线等待。。。。。****
2.sql server有现成的工具导入文本文件
或则
编写程序将读取excel文件数据,进行整理后,插入sql server
insert into Pub_SettleStyle
(cRPFlag,cSettleStyleCode,cSettleStyleID,cSubjectID,vcMemo,vcSettleStyleName) select temp.cRPFlag,temp.cSettleStyleCode,temp.cSettleStyleID,temp.cSubjectID,temp.vcMemo,temp.vcSettleStyleName from OPENROWSET('Microsoft.Jet.OLEDB.4.0','FileName';'admin';'',Pub_SettleStyle) As tempgo
var
i, j, iLengthIndex, iGridRow: integer; //iGridRow---For Excel時Grid專用
sFileName, sTmp, temp: string; ExcelApp, MyWordBook: OleVariant; //For Excel
iExcelCol : Integer; //For Excel
bError, bRun : Boolean; OpenHH.Filter := 'Excel檔(*.xls)|*.xls';
if OpenHH.Execute then
begin
bRun := True;
sFileName := Trim(OpenHH.FileName);
if (sFileName = '') or (not FileExists(sFileName)) then Exit;
try
grdMain.ClearNormalCells;//grdMain:TAdvStringGrid or TStringGrid
grdMain.RowCount := 2;
grdMain.row := 1;
iGridRow := 1; try
ExcelApp := CreateOLeObject('Excel.application');
MyWordBook := CreateOLeObject('Excel.Sheet');
MyWordBook := ExcelApp.WorkBooks.Open(sFileName); BtnOpen.Enabled := False;
//iExcelRow Excel文檔起始列
for i := iExcelRow to 999999 do
begin
grdMain.Cells[0, iGridRow] := '*';
grdMain.Cells[1, iGridRow] := IntToStr(iGridRow);
//向Grid中賦值
temp := Trim(MyWordBook.WorkSheets[1].Cells[i, 1].Value);
if temp = '' then Break;
//sDisplayCol 是否轉入的列
for j := 0 to sDisplayCol.Count - 1 do
begin
temp := Trim(MyWordBook.WorkSheets[1].Cells[i, 1].Value);
if temp = '' then Break;
//strExcelField[j] Excel轉入檔
iExcelCol := ConverExcelToSerial(strExcelField[j]);
//取相應列的值
sTmp := Trim(MyWordBook.WorkSheets[1].Cells[i, iExcelCol].Value);
//strLenth[j] 欄位長度
temp := trim(Copy(sTmp, 0, StrToInt(strLenth[j])));
//賦值給相應的列
grdMain.Cells[StrToInt(sDisplayCol[j]), iGridRow] := temp;
end;
if iGridRow > 1 then
grdMain.RowCount := grdMain.RowCount + 1;
Inc(iGridRow);
Application.ProcessMessages;
end;
ExcelApp.WorkBooks.Close;
grdMain.Row := grdMain.RowCount - 1;
grdMain.setfocus;
BtnOK.Enabled := True;
bError := False;
except
bError := True;
//Application.MessageBox('Can Not Open xls files','',Mb_ok+Mb_IconStop);
ExcelApp.WorkBooks.Close;
end;
ExcelApp := Unassigned;
MyWordBook := Unassigned;
Screen.Cursor := crDefault;
except
bError := True;
ExcelApp := Unassigned;
MyWordBook := Unassigned;
Screen.Cursor := crDefault;
end;
end;
若,不同,可利用sql语句来实现
简单、好用、快速、直接、易扩展。。
真乃编程、维护必备良药!