使用sql语句导入 如下: select cast(fdate as datetime) fdate,cast(forderno as varchar) forderno,cast(fnumber as varchar) fnumber, cast(fqty as decimal(28,10)) fqty,cast(fprice as decimal(28,10)) fprice,cast(famount as decimal(28,10)) famount, cast(freceiver as varchar) freceiver,cast(ffetchadd as varchar) ffetchadd, cast(ffetchstyle as varchar) ffetchstyle,cast(fnote as varchar) fnote,cast(fstockflag as varchar) fstockflag,'' ferrorflag from OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;hdr=yes;Database=D:\TEST.xls', [Sheet1$]) where isnull(frelateflag,'')<>'Y' order by forderno
如果格式不固定,则需要根据cell[i,j]中内容来判断了~~例子1: if cell[i,j]='日期' then cell[i,j+1]:=datetostr(now);//在日期下面的格子填日期 例子2: if cell[i,j]='日期' then cell[i+1,1]:=datetostr(now);//在日期左边的格子填日期
既然格式固定,也就是导入到stringgrid中的cell也是固定的了~~~
然后根据cell[i,j]来填充数据~~
至于保存应该不是问题了吧~~~
select cast(fdate as datetime) fdate,cast(forderno as varchar) forderno,cast(fnumber as varchar) fnumber,
cast(fqty as decimal(28,10)) fqty,cast(fprice as decimal(28,10)) fprice,cast(famount as decimal(28,10)) famount,
cast(freceiver as varchar) freceiver,cast(ffetchadd as varchar) ffetchadd,
cast(ffetchstyle as varchar) ffetchstyle,cast(fnote as varchar) fnote,cast(fstockflag as varchar) fstockflag,'' ferrorflag from
OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;hdr=yes;Database=D:\TEST.xls', [Sheet1$])
where isnull(frelateflag,'')<>'Y'
order by forderno
既然格式固定,也就是导入到stringgrid中的cell也是固定的了~~~
然后根据cell[i,j]来填充数据~~
至于保存应该不是问题了吧~~~
------------------------------------------------------------------------------------
你可以说详细一点吗?还有我所说的模板是可以改变的,也就是说里面的列数可以增加和减少,我应该怎么样去判断这个模板有多少列,还有每列的内容(字段名称)。
if cell[i,j]='日期' then
cell[i,j+1]:=datetostr(now);//在日期下面的格子填日期
例子2:
if cell[i,j]='日期' then
cell[i+1,1]:=datetostr(now);//在日期左边的格子填日期