在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
TXLSReadWriteII2 按行读取数据(写得复杂了点,实际项目中的,可以自己简化)
procedure TformMain.LoadGeneralObject(_type, _col, _row: Integer; _filename: AnsiString); var xls: TXLSReadWriteII2; i: integer; dataRec: TDataRec; reportedRec: TReportedRec;
RegistrationNO: AnsiString; StartstopTime: AnsiString; LastTime: AnsiString; Ownedcompanies: AnsiString; SimNO: AnsiString;
TerminalIDHex: AnsiString; TerminalIDStr: AnsiString; begin RzProgressBar1.Percent := 0; i := 0;
xls := TXLSReadWriteII2.Create(Self); try Xls.Filename := _filename; Xls.Read; //必须的
Xls.Sheet[0].LastCol := _col; Xls.Sheet[0].LastRow := _row;
case _type of 1: i := 1; 2: i := 2; end;
while i <= Xls.Sheet[0].LastRow do begin case _type of 1: begin reportedRec.ID := StrToIntDef(XLS.Sheets[0].AsFmtString[0, i], 0); Ownedcompanies := XLS.Sheets[0].AsFmtString[1, i]; reportedRec.Ownedcompanies := FilterChar(Ownedcompanies); RegistrationNO := XLS.Sheets[0].AsFmtString[2, i]; reportedRec.RegistrationNO := Q_StrTok1(RegistrationNO, '-'); reportedRec.Industry := FilterChar(XLS.Sheets[0].AsFmtString[3, i]); reportedRec.Dealer := FilterChar(XLS.Sheets[0].AsFmtString[4, i]); reportedRec.SimNO := FilterChar(XLS.Sheets[0].AsFmtString[6, i]); reportedRec.TerminalFactory := FilterChar(XLS.Sheets[0].AsFmtString[7, i]); TerminalIDHex := FilterChar(XLS.Sheets[0].AsFmtString[8, i]); TerminalIDStr := Trim(Q_StrTok1(TerminalIDHex, '/')); reportedRec.TerminalIDInt := StrToInt64Def(TerminalIDStr, 0); TerminalIDHex := Trim(TerminalIDHex); Q_Delete(TerminalIDHex, 1, 2); reportedRec.TerminalIDHex := TerminalIDHex; reportedRec.Reported := XLS.Sheets[0].AsFmtString[9, i] = '已上报'; reportedRec.isReported := True;
AddReportInfo(reportedRec); inc(i, 2); end; 2: begin dataRec.ID := StrToIntDef(XLS.Sheets[0].AsFmtString[0, i], 0); dataRec.VendorID := StrToIntDef(XLS.Sheets[0].AsFmtString[1, i], 0); dataRec.TerminalIDHex := XLS.Sheets[0].AsFmtString[2, i]; TerminalIDStr := XLS.Sheets[0].AsFmtString[3, i]; dataRec.TerminalIDInt := StrToIntDef(TerminalIDStr, 0); dataRec.TerminalKind := IfThen(Q_CopyLeft(TerminalIDStr, 1) = '4', 600, 700); dataRec.CenterID := StrToIntDef(XLS.Sheets[0].AsFmtString[4, i], 0); dataRec.CommType := XLS.Sheets[0].AsFmtString[5, i]; Ownedcompanies := XLS.Sheets[0].AsFmtString[6, i]; dataRec.Ownedcompanies := FilterChar(Ownedcompanies); RegistrationNO := XLS.Sheets[0].AsFmtString[7, i]; if Trim(RegistrationNO) = '' then dataRec.RegistrationNO := '' else dataRec.RegistrationNO := Q_StrTok1(RegistrationNO, '-');
SimNO := XLS.Sheets[0].AsFmtString[8, i]; dataRec.SimNO := FilterChar(SimNO); dataRec.Reported := XLS.Sheets[0].AsFmtString[13, i] = '√'; dataRec.BackInfo := XLS.Sheets[0].AsFmtString[14, i] = '√'; StartstopTime := XLS.Sheets[0].AsFmtString[15, i]; if StartstopTime = '' then begin dataRec.StartstopTime := ''; dataRec.LastTime := 0; end else begin StartstopTime := FilterChar(StartstopTime); dataRec.StartstopTime := StartstopTime; Q_StrTok1(StartstopTime, '~'); LastTime := FormatDateTime('yyyy-', Now) + StartstopTime; dataRec.LastTime := StrToDateTime(LastTime); end; dataRec.RealTime := 0;
AddCarGeneralInfo(dataRec); inc(i); end; end;
doOnProgressBar(100 * i div Xls.Sheet[0].LastRow); end; finally xls.Free; end; end; |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论