浏览 2907 次
锁定老帖子 主题:用Java读写多种格式的电子文档的方案
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-04-25
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2008-04-25
对文件本身的操作就使用poi,jxl等开源项目,如果导入导出的格式不会经常发生变化,将“定义”和“执行”分开,例如在xml中定义导入导出的所有参数格式:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE project SYSTEM "D:\eclipse\workspace\gds\src\dtsMap.dtd"> <project name="database conversion"> <source-definition> <!-- <source type="db" name="stock" url="jdbc:sybase:Tds:10.16.120.44:5000/pbzq" driver="com.sybase.jdbc2.jdbc.SybDriver" username="sa" password="888888" className="com.gds.util.dts.DatabaseDefine"> <set-property property="description" value="Example Data Source Configuration"/> </source> <source type="db" name="found" url="jdbc:sybase:Tds:10.16.120.44:5000/pbzq" driver="com.sybase.jdbc2.jdbc.SybDriver" username="sa" password="888888" className=""> <set-property property="description" value="Example Data Source Configuration"/> </source> --> <!-- 定义"源"位置,可以是数据库、ftp服务器、email服务期、共享文件夹等形式 --> <source type="ftp" name="ftpsource" url="ip:port/dir" driver="" username="username" password="passowrd" className="com.gds.util.dts.FtpSource"> <set-property property="description" value="Example Data Source Configuration"/> </source> </source-definition> <dts-package> <package name="db2db" type="db2db" source="stock" destination="found" translator="com.gds.util.dts.DatabaseTranslator" className=""> <set-property property="description" value="Example Data Source Configuration"/> <table-map name="" source="select * from zhk" destination="cashaccount"> <field-map source="fzjzh" destination="CASHACCOUNTID"/> <field-map source="fkhrq" destination="OPENACCOUNTDATE"/> <field-map source="fqkfs" destination="DRAWTYPE"/> <field-map source="substring(fzjzh,1,2)" destination="OFFICEID"/> <field-map source="" destination="CASHORIGIN"/> <set-property property="description" value="Example Data Source Configuration"/> </table-map> <table-map source="select * from tskhsfblb,zhzl where tskhsfblb.fzjzh = zhzl.fzjzh " destination="shareholderrebate"> <field-map source="zhzl.fgddm" destination="SHAREHOLDER"/> <field-map source="convert(char(1),tskhsfblb.fscdm)+convert(char(2),tskhsfblb.fgplb)" destination="SHARETYPE"/> <field-map source="tskhsfblb.fssfl" destination="REBATE"/> <set-property property="description" value="Example Data Source Configuration"/> </table-map> </package> <package name="db2excel" type="db2excel" source="stock" destination="ftpsource" translator="com.gds.util.dts.Database2ExcelTranslator" className=""> <set-property property="description" value="Example Data Source Configuration"/> <table-map name="" source="select * from zhk" destination="testWorkbook.testSheet"> <field-map source="fzjzh" destination="0,0"/> <field-map source="fkhrq" destination="0,1"/> <field-map source="fqkfs" destination="2,3"/> <field-map source="substring(fzjzh,1,2)" destination="4,8"/> <field-map source="test" destination="3,5"/> </table-map> </package> <package name="excel2db" type="excel2db" source="stock" destination="stock" translator="com.gds.util.dts.Excel2DatabaseTranslator" className=""> <set-property property="description" value="Example Data Source Configuration"/> <table-map name="" source="testWorkbook.testSheet" destination="cashaccount"> <field-map source="0,0" destination="fzjzh"/> <field-map source="0,1" destination="fkhrq"/> <field-map source="2,3" destination="fqkfs"/> <field-map source="4,8" destination="fzjzh"/> <field-map source="3,5" destination="test"/> </table-map> </package> </dts-package> </project> |
|
返回顶楼 | |
发表时间:2008-04-29
taelons 写道 对文件本身的操作就使用poi,jxl等开源项目,如果导入导出的格式不会经常发生变化,将“定义”和“执行”分开,例如在xml中定义导入导出的所有参数格式:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE project SYSTEM "D:\eclipse\workspace\gds\src\dtsMap.dtd"> <project name="database conversion"> <source-definition> <!-- <source type="db" name="stock" url="jdbc:sybase:Tds:10.16.120.44:5000/pbzq" driver="com.sybase.jdbc2.jdbc.SybDriver" username="sa" password="888888" className="com.gds.util.dts.DatabaseDefine"> <set-property property="description" value="Example Data Source Configuration"/> </source> <source type="db" name="found" url="jdbc:sybase:Tds:10.16.120.44:5000/pbzq" driver="com.sybase.jdbc2.jdbc.SybDriver" username="sa" password="888888" className=""> <set-property property="description" value="Example Data Source Configuration"/> </source> --> <!-- 定义"源"位置,可以是数据库、ftp服务器、email服务期、共享文件夹等形式 --> <source type="ftp" name="ftpsource" url="ip:port/dir" driver="" username="username" password="passowrd" className="com.gds.util.dts.FtpSource"> <set-property property="description" value="Example Data Source Configuration"/> </source> </source-definition> <dts-package> <package name="db2db" type="db2db" source="stock" destination="found" translator="com.gds.util.dts.DatabaseTranslator" className=""> <set-property property="description" value="Example Data Source Configuration"/> <table-map name="" source="select * from zhk" destination="cashaccount"> <field-map source="fzjzh" destination="CASHACCOUNTID"/> <field-map source="fkhrq" destination="OPENACCOUNTDATE"/> <field-map source="fqkfs" destination="DRAWTYPE"/> <field-map source="substring(fzjzh,1,2)" destination="OFFICEID"/> <field-map source="" destination="CASHORIGIN"/> <set-property property="description" value="Example Data Source Configuration"/> </table-map> <table-map source="select * from tskhsfblb,zhzl where tskhsfblb.fzjzh = zhzl.fzjzh " destination="shareholderrebate"> <field-map source="zhzl.fgddm" destination="SHAREHOLDER"/> <field-map source="convert(char(1),tskhsfblb.fscdm)+convert(char(2),tskhsfblb.fgplb)" destination="SHARETYPE"/> <field-map source="tskhsfblb.fssfl" destination="REBATE"/> <set-property property="description" value="Example Data Source Configuration"/> </table-map> </package> <package name="db2excel" type="db2excel" source="stock" destination="ftpsource" translator="com.gds.util.dts.Database2ExcelTranslator" className=""> <set-property property="description" value="Example Data Source Configuration"/> <table-map name="" source="select * from zhk" destination="testWorkbook.testSheet"> <field-map source="fzjzh" destination="0,0"/> <field-map source="fkhrq" destination="0,1"/> <field-map source="fqkfs" destination="2,3"/> <field-map source="substring(fzjzh,1,2)" destination="4,8"/> <field-map source="test" destination="3,5"/> </table-map> </package> <package name="excel2db" type="excel2db" source="stock" destination="stock" translator="com.gds.util.dts.Excel2DatabaseTranslator" className=""> <set-property property="description" value="Example Data Source Configuration"/> <table-map name="" source="testWorkbook.testSheet" destination="cashaccount"> <field-map source="0,0" destination="fzjzh"/> <field-map source="0,1" destination="fkhrq"/> <field-map source="2,3" destination="fqkfs"/> <field-map source="4,8" destination="fzjzh"/> <field-map source="3,5" destination="test"/> </table-map> </package> </dts-package> </project> 楼上的老兄,我还是有点迷糊,能不能给个源码过来 |
|
返回顶楼 | |