| 发表于:2007-07-12 15:43:116楼 得分:0 |
和sql server操作类似的: dim conn as new data.oledb.oledbconnection( "provider=microsoft.jet.oledb.4.0;data source=c:\documents and settings\weichen\桌面\新建 microsoft excel 工作表.xls;extended properties=excel 8.0; ") conn.open() dim comm as new oledb.oledbcommand comm.commandtext = "insert into [sheet1$] values( ' ') " comm.commandtype = commandtype.text comm.connection = conn comm.EXECutenonquery() 更简单的: dim mytext as string= " " dim myc as integer = ds.tables(0).columns.count - 1 dim myr as integer = ds.tables(0).rows.count - 1 dim i as integer dim j as integer for j = 0 to myc mytext += ds.tables(0).columns(j).columnname & chr(9) next mytext += chr(10) for i = 0 to myr for j = 0 to myc mytext += ds.tables(0).rows(i).item(j).tostring & chr(9) next mytext += chr(10) next dim sw as new streamwriter( "excel文件地址 ".text, true, system.text.encoding.getencoding( "gb2312 ")) sw.write(mytext) sw.close() sw.dispose() | | |
|