- 浏览: 15892 次
- 性别:
- 来自: 北京
-
最近访客 更多访客>>
文章分类
最新评论
-
王俊18701460384:
SQLServer生成insert语句 -
nk12386:
楼主真的很强啊,我找了好久才找到啊,真的很好用啊,以后 ...
SQLServer生成insert语句
package com.sinosoft.lz.emergency.print; import java.awt.Color; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.Iterator; import java.util.List; import javax.ws.rs.core.Context; import org.apache.log4j.Logger; import com.lowagie.text.Cell; import com.lowagie.text.Document; import com.lowagie.text.Element; import com.lowagie.text.Font; import com.lowagie.text.FontFactory; import com.lowagie.text.Image; import com.lowagie.text.PageSize; import com.lowagie.text.Paragraph; import com.lowagie.text.Phrase; import com.lowagie.text.Table; import com.lowagie.text.pdf.BaseFont; import com.lowagie.text.rtf.RtfWriter2; import com.persistence.service.PersistenceFactory; import com.persistence.service.SysPersistence; import com.sinosoft.lz.emergency.dao.FloodDao; import com.sinosoft.lz.emergency.service.EmergencyEventImp; import com.sinosoft.lz.emergency.service.EquipmentNumImp; import com.sinosoft.lz.emergency.service.MaterialNumImp; import com.sinosoft.lz.emergency.service.SelectedExpertServiceImp; import com.sinosoft.lz.emergency.vo.Command; import com.sinosoft.lz.emergency.vo.Commands; import com.sinosoft.lz.emergency.vo.EquipmentNum; import com.sinosoft.lz.emergency.vo.EquipmentNums; import com.sinosoft.lz.emergency.vo.ExpertInfo; import com.sinosoft.lz.emergency.vo.ExpertInfos; import com.sinosoft.lz.emergency.vo.FloodContinueInfo; import com.sinosoft.lz.emergency.vo.FloodEventInfo; import com.sinosoft.lz.emergency.vo.FloodFirstInfo; import com.sinosoft.lz.emergency.vo.MaterialNum; import com.sinosoft.lz.emergency.vo.MaterialNums; import com.sysmodel.datamodel.xmlmodel.ModelFactory; import com.sysmodel.datamodel.xmlmodel.able.SysModel; public class CreateWord{ private final Logger log = Logger.getLogger(getClass()); private SysModel sysmodel = ModelFactory.getSysmodel(); private SysPersistence persistence = PersistenceFactory.getInstance(sysmodel); public void createDocContext(String file,String contentTempPath,String PREPARATION_PRIJECT_Code,String FD_OBJECTID,String classId, String sessionID,String userID) throws Exception{ EmergencyEventImp emergencyEventImp = new EmergencyEventImp(); FloodDao floodDao=new FloodDao(); //根据应急事件ID获取事件首报和续报信息 FloodEventInfo floodEventInfo=floodDao.getFloodFCInfo(FD_OBJECTID); FloodFirstInfo firstInfo=floodEventInfo.getFirstInfo(); ArrayList<FloodContinueInfo> continueInfo=(ArrayList<FloodContinueInfo>)floodEventInfo.getContinueInf(); Iterator<FloodContinueInfo> continueInf= continueInfo.iterator(); // 设置纸张大小 Document document = new Document(PageSize.A4); // 建立一个书写器(Writer)与document对象关联,通过书写器(Writer)可以将文档写入到磁盘中 RtfWriter2.getInstance(document, new FileOutputStream(file)); document.open(); // 设置中文字体 BaseFont bfChinese = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // 标题字体风格 Font titleFont = new Font(bfChinese, 12, Font.BOLD); // 正文字体风格 //Font contextFont = new Font(bfChinese, 10, Font.NORMAL); Paragraph title = new Paragraph("应急报告",FontFactory.getFont( FontFactory.HELVETICA_BOLDOBLIQUE, 18, Font.BOLD, new Color(0,0,0))); // 设置标题格式对齐方式 title.setAlignment(Element.ALIGN_CENTER); title.setFont(titleFont); document.add(title); DateFormat df = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒"); String time1=df.format(new Date()); String contextString = "报告时间:"+time1; Paragraph context = new Paragraph(contextString); // 正文格式左对齐 context.setAlignment(Element.ALIGN_LEFT); // 离上一段落(标题)空的行数 context.setSpacingBefore(5); // 设置第一行空的列数 context.setFirstLineIndent(20); document.add(context); //利用类FontFactory结合Font和Color可以设置各种各样字体样式 /** * Font.UNDERLINE 下划线,Font.BOLD 粗体 */ Paragraph underline = new Paragraph("一、应急首报信息", FontFactory.getFont( FontFactory.HELVETICA_BOLDOBLIQUE, 13, Font.BOLD, new Color(0,0,0))); document.add(underline); // 设置 Table 表格 Table aTable = new Table(6); int width[] = {20,20,20,20,20,20}; aTable.setWidths(width);//设置每列所占比例 aTable.setWidth(90); // 占页面宽度 90% aTable.setAlignment(Element.ALIGN_CENTER);//居中显示 aTable.setAlignment(Element.ALIGN_MIDDLE);//纵向居中显示 aTable.setAutoFillEmptyCells(true); //自动填满 aTable.setBorderWidth(5); //边框宽度 aTable.setBorderColor(new Color(0, 125, 255)); //边框颜色 aTable.setPadding(5);//衬距,看效果就知道什么意思了 aTable.setSpacing(0);//即单元格之间的间距 aTable.setBorder(5);//边框 aTable.getDefaultCell().setBorder(0);//无边框 //设置表头 /** * cell.setHeader(true);是将该单元格作为表头信息显示; * cell.setColspan(3);指定了该单元格占3列; * 为表格添加表头信息时,要注意的是一旦表头信息添加完了之后, * 必须调用 endHeaders()方法,否则当表格跨页后,表头信息不会再显示 */ aTable.addCell(new Cell("路线编号")); aTable.addCell(new Cell(firstInfo.getRoadcode())); aTable.addCell(new Cell("路线名称")); aTable.addCell(new Cell(firstInfo.getRoadname())); aTable.addCell(new Cell("事件所在位置")); aTable.addCell(new Cell(firstInfo.getRoadpos())); aTable.addCell(new Cell("起点桩号")); aTable.addCell(new Cell(firstInfo.getStartpileno())); aTable.addCell(new Cell("止点桩号")); aTable.addCell(new Cell(firstInfo.getEndpileno())); aTable.addCell(new Cell("填报人")); aTable.addCell(new Cell(firstInfo.getReoprtperson())); aTable.addCell(new Cell("行政区划")); aTable.addCell(new Cell(firstInfo.getAreacode())); aTable.addCell(new Cell("路线管理单位")); aTable.addCell(new Cell(firstInfo.getDept())); aTable.addCell(new Cell("联系电话")); aTable.addCell(new Cell(firstInfo.getTel())); aTable.addCell(new Cell("事件类型")); aTable.addCell(new Cell(firstInfo.getEventtype())); aTable.addCell(new Cell("经度")); aTable.addCell(new Cell(firstInfo.getLongitude())); aTable.addCell(new Cell("纬度")); aTable.addCell(new Cell(firstInfo.getLatitude())); aTable.addCell(new Cell("事件级别")); aTable.addCell(new Cell(firstInfo.getEventlevel())); aTable.addCell(new Cell("发现时间")); Cell cell3 = new Cell(new Phrase(firstInfo.getFindtime())); cell3.setColspan(3); cell3.setVerticalAlignment(Element.ALIGN_CENTER); aTable.addCell(cell3); aTable.addCell(new Cell("现场情况描述")); Cell cell4 = new Cell(new Phrase(firstInfo.getDescription())); cell4.setColspan(5); cell4.setVerticalAlignment(Element.ALIGN_CENTER); aTable.addCell(cell4); aTable.addCell(new Cell("车道数")); aTable.addCell(new Cell(firstInfo.getDrivewaynum())); aTable.addCell(new Cell("占用车道数")); Cell cell5 = new Cell(new Phrase(firstInfo.getBlockdrivewaynum())); cell5.setColspan(3); cell5.setVerticalAlignment(Element.ALIGN_CENTER); aTable.addCell(cell5); aTable.addCell(new Cell("阻断类型")); aTable.addCell(new Cell(firstInfo.getBlocktype())); aTable.addCell(new Cell("所属单位")); Cell cell6 = new Cell(new Phrase(firstInfo.getDept_id())); cell6.setColspan(3); cell6.setVerticalAlignment(Element.ALIGN_CENTER); aTable.addCell(cell6); document.add(aTable); document.add(new Paragraph("\n")); Paragraph pacti = new Paragraph("二、首报图片信息", FontFactory.getFont( FontFactory.HELVETICA_BOLDOBLIQUE, 13, Font.BOLD, new Color(0,0,0))); document.add(pacti); synchronized (this) { List<String> string = getPicStr(FD_OBJECTID,contentTempPath);//图片路径 for(String str:string){ //添加图片 Image img=Image.getInstance(str); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);//设置图片显示位置 img.scaleAbsolute(12,35);//直接设定显示尺寸 img.scalePercent(50);//表示显示的大小为原尺寸的50% img.scalePercent(25, 12);//图像高宽的显示比例 img.setRotation(30);//图像旋转一定角度 document.add(img); } System.out.println("图片路径:"+string); /* * 删除图片 * */ deletePic(string); } document.add(new Paragraph("\n")); Paragraph underxubao = new Paragraph("三、应急续报信息", FontFactory.getFont( FontFactory.HELVETICA_BOLDOBLIQUE, 13, Font.BOLD, new Color(0,0,0))); document.add(underxubao); // 设置 Table 表格 if(continueInf.hasNext()){ for(FloodContinueInfo fci:continueInfo){ Table xubao = new Table(4); int xb[] = {20,20,20,20}; xubao.setWidths(xb);//设置每列所占比例 xubao.setWidth(90); // 占页面宽度 90% xubao.setAlignment(Element.ALIGN_CENTER);//居中显示 xubao.setAlignment(Element.ALIGN_MIDDLE);//纵向居中显示 xubao.setAutoFillEmptyCells(true); //自动填满 xubao.setBorderWidth(5); //边框宽度 xubao.setBorderColor(new Color(0, 125, 255)); //边框颜色 xubao.setPadding(5);//衬距,看效果就知道什么意思了 xubao.setSpacing(0);//即单元格之间的间距 xubao.setBorder(5);//边框 xubao.addCell(new Cell("上报单位")); xubao.addCell(new Cell(fci.getReportdept())); xubao.addCell(new Cell("上报时间")); xubao.addCell(new Cell(fci.getReporttime())); xubao.addCell(new Cell("降水情况")); xubao.addCell(new Cell(fci.getPrecipitationlevel())); xubao.addCell(new Cell("巡查投入人数")); xubao.addCell(new Cell(fci.getPatrol_personnum())); xubao.addCell(new Cell("巡查投入车辆数")); xubao.addCell(new Cell(fci.getPatrol_carnum())); xubao.addCell(new Cell("抢险投入人数")); xubao.addCell(new Cell(fci.getEmergency_pernum())); xubao.addCell(new Cell("机械设备总数")); xubao.addCell(new Cell(fci.getEmergency_equipmentnum())); xubao.addCell(new Cell("运输车")); xubao.addCell(new Cell(fci.getEmergency_transportcar())); xubao.addCell(new Cell("铲吊车")); xubao.addCell(new Cell(fci.getEmergency_crane())); xubao.addCell(new Cell("发电机")); xubao.addCell(new Cell(fci.getEmergency_dynam())); xubao.addCell(new Cell("水泵")); xubao.addCell(new Cell(fci.getEmergency_waterpump())); xubao.addCell(new Cell("草袋")); xubao.addCell(new Cell(fci.getEmergency_strawbag())); xubao.addCell(new Cell("麻袋")); xubao.addCell(new Cell(fci.getEmergency_jutebag())); xubao.addCell(new Cell("编织袋")); xubao.addCell(new Cell(fci.getEmergency_braidedbag())); xubao.addCell(new Cell("无纺布")); xubao.addCell(new Cell(fci.getEmergency_nonwoven())); xubao.addCell(new Cell("铅丝(螺纹钢)")); xubao.addCell(new Cell(fci.getEmergency_wire())); xubao.addCell(new Cell("桩木")); xubao.addCell(new Cell(fci.getEmergency_pile())); xubao.addCell(new Cell("砂石料")); xubao.addCell(new Cell(fci.getEmergency_ballast())); xubao.addCell(new Cell("大型作业灯")); xubao.addCell(new Cell(fci.getEmergency_workinglight())); xubao.addCell(new Cell("路面塌陷线路名称")); xubao.addCell(new Cell(fci.getSubside_roadname())); xubao.addCell(new Cell("路线编号")); xubao.addCell(new Cell(fci.getSubside_roadcode())); xubao.addCell(new Cell("位置(桩号)")); xubao.addCell(new Cell(fci.getSubside_roadpos())); xubao.addCell(new Cell("阻断情况")); xubao.addCell(new Cell(fci.getSubside_blocktype())); xubao.addCell(new Cell("占车道数")); xubao.addCell(new Cell(fci.getSubside_blocknum())); xubao.addCell(new Cell("塌方线路名称")); xubao.addCell(new Cell(fci.getLandslide_roadname())); xubao.addCell(new Cell("路线编号")); xubao.addCell(new Cell(fci.getLandslide_roadcode())); xubao.addCell(new Cell("位置(桩号)")); xubao.addCell(new Cell(fci.getLandslide_roadpos())); xubao.addCell(new Cell("面积")); xubao.addCell(new Cell(fci.getLandslide_area())); xubao.addCell(new Cell("方向")); xubao.addCell(new Cell(fci.getLandslide_direction())); xubao.addCell(new Cell("阻断情况")); xubao.addCell(new Cell(fci.getLandslide_blocktype())); xubao.addCell(new Cell("占车道数")); xubao.addCell(new Cell(fci.getLandslide_blocknum())); xubao.addCell(new Cell("路基水毁线路名称")); xubao.addCell(new Cell(fci.getDamage_roadname())); xubao.addCell(new Cell("线路编号")); xubao.addCell(new Cell(fci.getDamage_roadcode())); xubao.addCell(new Cell("位置(桩号)")); xubao.addCell(new Cell(fci.getDamage_roadpos())); xubao.addCell(new Cell("面积")); xubao.addCell(new Cell(fci.getDamage_area())); xubao.addCell(new Cell("阻断情况")); xubao.addCell(new Cell(fci.getDamage_blocktype())); xubao.addCell(new Cell("占车道数")); xubao.addCell(new Cell(fci.getDamage_blocknum())); xubao.addCell(new Cell("路面积水线路名称")); xubao.addCell(new Cell(fci.getSeeper_roadname())); xubao.addCell(new Cell("线路编号")); xubao.addCell(new Cell(fci.getSeeper_roadcode())); xubao.addCell(new Cell("位置(桩号)")); xubao.addCell(new Cell(fci.getSeeper_roadpos())); xubao.addCell(new Cell("面积")); xubao.addCell(new Cell(fci.getSeeper_area())); xubao.addCell(new Cell("路基水毁线路名称")); xubao.addCell(new Cell(fci.getSeeper_depth())); xubao.addCell(new Cell("路面积水阻断情况")); xubao.addCell(new Cell(fci.getSeeper_blocktype())); xubao.addCell(new Cell("路面积水占车道数")); xubao.addCell(new Cell(fci.getSeeper_blocknum())); xubao.addCell(new Cell("上报人")); xubao.addCell(new Cell(fci.getReporter())); xubao.addCell(new Cell("联系电话")); xubao.addCell(new Cell(fci.getReporttel())); xubao.addCell(new Cell("其它需要说明的问题备注")); Cell cell7 = new Cell(new Phrase(fci.getRemark())); cell7.setColspan(3); cell7.setVerticalAlignment(Element.ALIGN_CENTER); xubao.addCell(cell7); document.add(xubao); } }else{ Table xubao = new Table(4); int xb[] = {20,20,20,20}; xubao.setWidths(xb);//设置每列所占比例 xubao.setWidth(90); // 占页面宽度 90% xubao.setAlignment(Element.ALIGN_CENTER);//居中显示 xubao.setAlignment(Element.ALIGN_MIDDLE);//纵向居中显示 xubao.setAutoFillEmptyCells(true); //自动填满 xubao.setBorderWidth(5); //边框宽度 xubao.setBorderColor(new Color(0, 125, 255)); //边框颜色 xubao.setPadding(5);//衬距,看效果就知道什么意思了 xubao.setSpacing(0);//即单元格之间的间距 xubao.setBorder(5);//边框 xubao.addCell(new Cell("上报单位")); xubao.addCell(new Cell()); xubao.addCell(new Cell("上报时间")); xubao.addCell(new Cell()); xubao.addCell(new Cell("降水情况")); xubao.addCell(new Cell()); xubao.addCell(new Cell("巡查投入人数")); xubao.addCell(new Cell()); xubao.addCell(new Cell("巡查投入车辆数")); xubao.addCell(new Cell()); xubao.addCell(new Cell("抢险投入人数")); xubao.addCell(new Cell()); xubao.addCell(new Cell("机械设备总数")); xubao.addCell(new Cell()); xubao.addCell(new Cell("运输车")); xubao.addCell(new Cell()); xubao.addCell(new Cell("铲吊车")); xubao.addCell(new Cell()); xubao.addCell(new Cell("发电机")); xubao.addCell(new Cell()); xubao.addCell(new Cell("水泵")); xubao.addCell(new Cell()); xubao.addCell(new Cell("草袋")); xubao.addCell(new Cell()); xubao.addCell(new Cell("麻袋")); xubao.addCell(new Cell()); xubao.addCell(new Cell("编织袋")); xubao.addCell(new Cell()); xubao.addCell(new Cell("无纺布")); xubao.addCell(new Cell()); xubao.addCell(new Cell("铅丝(螺纹钢)")); xubao.addCell(new Cell()); xubao.addCell(new Cell("桩木")); xubao.addCell(new Cell()); xubao.addCell(new Cell("砂石料")); xubao.addCell(new Cell()); xubao.addCell(new Cell("大型作业灯")); xubao.addCell(new Cell()); xubao.addCell(new Cell("路面塌陷线路名称")); xubao.addCell(new Cell()); xubao.addCell(new Cell("路线编号")); xubao.addCell(new Cell()); xubao.addCell(new Cell("位置(桩号)")); xubao.addCell(new Cell()); xubao.addCell(new Cell("阻断情况")); xubao.addCell(new Cell()); xubao.addCell(new Cell("占车道数")); xubao.addCell(new Cell()); xubao.addCell(new Cell("塌方线路名称")); xubao.addCell(new Cell()); xubao.addCell(new Cell("路线编号")); xubao.addCell(new Cell()); xubao.addCell(new Cell("位置(桩号)")); xubao.addCell(new Cell()); xubao.addCell(new Cell("面积")); xubao.addCell(new Cell()); xubao.addCell(new Cell("方向")); xubao.addCell(new Cell()); xubao.addCell(new Cell("阻断情况")); xubao.addCell(new Cell()); xubao.addCell(new Cell("占车道数")); xubao.addCell(new Cell()); xubao.addCell(new Cell("路基水毁线路名称")); xubao.addCell(new Cell()); xubao.addCell(new Cell("线路编号")); xubao.addCell(new Cell()); xubao.addCell(new Cell("位置(桩号)")); xubao.addCell(new Cell()); xubao.addCell(new Cell("面积")); xubao.addCell(new Cell()); xubao.addCell(new Cell("阻断情况")); xubao.addCell(new Cell()); xubao.addCell(new Cell("占车道数")); xubao.addCell(new Cell()); xubao.addCell(new Cell("路面积水线路名称")); xubao.addCell(new Cell()); xubao.addCell(new Cell("线路编号")); xubao.addCell(new Cell()); xubao.addCell(new Cell("位置(桩号)")); xubao.addCell(new Cell()); xubao.addCell(new Cell("面积")); xubao.addCell(new Cell()); xubao.addCell(new Cell("路基水毁线路名称")); xubao.addCell(new Cell()); xubao.addCell(new Cell("路面积水阻断情况")); xubao.addCell(new Cell()); xubao.addCell(new Cell("路面积水占车道数")); xubao.addCell(new Cell()); xubao.addCell(new Cell("上报人")); xubao.addCell(new Cell()); xubao.addCell(new Cell("联系电话")); xubao.addCell(new Cell()); xubao.addCell(new Cell("其它需要说明的问题备注")); Cell cell7 = new Cell(new Phrase()); cell7.setColspan(3); cell7.setVerticalAlignment(Element.ALIGN_CENTER); xubao.addCell(cell7); document.add(xubao); } document.add(new Paragraph("\n")); Paragraph chuli = new Paragraph("四、处理步骤", FontFactory.getFont( FontFactory.HELVETICA_BOLDOBLIQUE, 13, Font.BOLD, new Color(0,0,0))); document.add(chuli); // 设置 Table 表格 Table cl = new Table(1); int chul[] = {20}; cl.setWidths(chul);//设置每列所占比例 cl.setWidth(90); // 占页面宽度 90% cl.setAlignment(Element.ALIGN_CENTER);//居中显示 cl.setAlignment(Element.ALIGN_MIDDLE);//纵向居中显示 cl.setAutoFillEmptyCells(true); //自动填满 cl.setBorderWidth(5); //边框宽度 cl.setBorderColor(new Color(0, 125, 255)); //边框颜色 cl.setPadding(5);//衬距,看效果就知道什么意思了 cl.setSpacing(0);//即单元格之间的间距 cl.setBorder(5);//边框 String FindTime=firstInfo.getFindtime(); String RoadCode=firstInfo.getRoadcode(); String Startpileno1=firstInfo.getStartpileno(); String Endpileno1=firstInfo.getEndpileno(); String contextString1="1、"+FindTime+"在"+RoadCode+"("+Startpileno1+"-"+Endpileno1+")"+"发生应急事件"; String contextString2 = "2、" + firstInfo.getMatchingTime() + " 匹配" + firstInfo.getPreparationid() + "预案,确认人" + firstInfo.getMatchingConfirmPerson() + "!"; String contextString3 = "3、" + firstInfo.getStartPPTime() + " 启动" + firstInfo.getPreparationid() + "预案,确认人" + firstInfo.getStartOperatePerson() + "!"; String contextString5 = ""; String allString=contextString1+"\n"+contextString2+"\n"+contextString3; //printInfo[60]=allString; // 获取指令登记对象集合 Commands commands = emergencyEventImp.getCommandList(FD_OBJECTID); // -------------获得下发指令--------------------------- ArrayList<Command> listcommand = (ArrayList<Command>) commands.getCommands(); Iterator<Command> itcommand = listcommand.iterator(); int i=4; if (itcommand.hasNext()) { while (itcommand.hasNext()) { Command command = (Command) itcommand.next(); String comandStr=""; comandStr=i+"、在" + command.getIssuedDate() + "下发指令" + command.getRemark() + ",由" + command.getConfirmor() + "下发给" + command.getAcceptPer() + "!"; contextString5+=comandStr+"\n"; i++; } cl.addCell(new Cell(allString+"\n"+contextString5+"\n")); document.add(cl); } else { contextString5 = " "+i+".无下发指令信息!"; //printInfo[68]=allString+contextString5; cl.addCell(new Cell(allString+contextString5)); document.add(cl); } document.add(new Paragraph("\n")); Paragraph material = new Paragraph("五、物资调用", FontFactory.getFont( FontFactory.HELVETICA_BOLDOBLIQUE, 13, Font.BOLD, new Color(0,0,0))); document.add(material); // 设置 Table 表格 Table mater = new Table(4); int ma[] = {20,20,20,20}; mater.setWidths(ma);//设置每列所占比例 mater.setWidth(90); // 占页面宽度 90% mater.setAlignment(Element.ALIGN_CENTER);//居中显示 mater.setAlignment(Element.ALIGN_MIDDLE);//纵向居中显示 mater.setAutoFillEmptyCells(true); //自动填满 mater.setBorderWidth(5); //边框宽度 mater.setBorderColor(new Color(0, 125, 255)); //边框颜色 mater.setPadding(5);//衬距,看效果就知道什么意思了 mater.setSpacing(0);//即单元格之间的间距 mater.setBorder(5);//边框 mater.addCell(new Cell("物资类型")); mater.addCell(new Cell("已有数量")); mater.addCell(new Cell("预案设置数量")); mater.addCell(new Cell("调用数量")); MaterialNumImp materialNumImp=new MaterialNumImp(); String parames="PREPARATION_PRIJECT_Code="+PREPARATION_PRIJECT_Code+"&eventId="+FD_OBJECTID; MaterialNums materialNums=materialNumImp.getMaterialListBus(parames); ArrayList<MaterialNum> listmaterial=(ArrayList<MaterialNum>)materialNums.getMaterialNum(); Iterator<MaterialNum> itmaterial =listmaterial.iterator(); //int index=69; if(listmaterial.size()==0){ mater.addCell(new Cell("")); mater.addCell(new Cell("")); mater.addCell(new Cell("")); mater.addCell(new Cell("")); } while(itmaterial.hasNext()){ MaterialNum materialNum=(MaterialNum)itmaterial.next(); String Fd_description=materialNum.getFD_DESCRIPTION(); String MATERIAL_Num=materialNum.getMATERIAL_NUM(); log.info("设备表中设备数量: "+MATERIAL_Num); String MATERIAL_Number=materialNum.getMATERIAL_NUNMBER(); log.info("设置数量: "+MATERIAL_Number); String MATERIAL_NumSum=materialNum.getMATERIAL_NUMSUM(); log.info("===: "+MATERIAL_NumSum); mater.addCell(new Cell(Fd_description)); mater.addCell(new Cell(MATERIAL_Num)); mater.addCell(new Cell(MATERIAL_Number)); mater.addCell(new Cell(MATERIAL_NumSum)); } document.add(mater); document.add(new Paragraph("\n")); Paragraph equment = new Paragraph("六、设备调用", FontFactory.getFont( FontFactory.HELVETICA_BOLDOBLIQUE, 13, Font.BOLD, new Color(0,0,0))); document.add(equment); // 设置 Table 表格 Table equ = new Table(4); int eq[] = {20,20,20,20}; equ.setWidths(eq);//设置每列所占比例 equ.setWidth(90); // 占页面宽度 90% equ.setAlignment(Element.ALIGN_CENTER);//居中显示 equ.setAlignment(Element.ALIGN_MIDDLE);//纵向居中显示 equ.setAutoFillEmptyCells(true); //自动填满 equ.setBorderWidth(5); //边框宽度 equ.setBorderColor(new Color(0, 125, 255)); //边框颜色 equ.setPadding(5);//衬距,看效果就知道什么意思了 equ.setSpacing(0);//即单元格之间的间距 equ.setBorder(5);//边框 equ.addCell(new Cell("物资类型")); equ.addCell(new Cell("已有数量")); equ.addCell(new Cell("预案设置数量")); equ.addCell(new Cell("调用数量")); EquipmentNumImp equipmentNumImp = new EquipmentNumImp(); String params = "PREPARATION_PRIJECT_Code=" + PREPARATION_PRIJECT_Code + "&eventId=" + FD_OBJECTID; EquipmentNums equipmentNums = equipmentNumImp.getEquipmentListBus(params); ArrayList<EquipmentNum> listequment = (ArrayList<EquipmentNum>) equipmentNums .getEquipmentNum(); Iterator<EquipmentNum> itequment = listequment.iterator(); if(listequment.size()==0){ equ.addCell(new Cell("")); equ.addCell(new Cell("")); equ.addCell(new Cell("")); equ.addCell(new Cell("")); } while (itequment.hasNext()) { EquipmentNum equipmentNum = (EquipmentNum) itequment.next(); String Fd_description=equipmentNum.getFD_DESCRIPTION(); String EQUIPMENT_Num = equipmentNum.getEQUIPMENT_NUM(); String EQUIPMENT_Number = equipmentNum.getEQUIPMENT_NUMBER(); String EQUIPMENT_NumSum = equipmentNum.getEQUIPMENT_NUMSUM(); equ.addCell(new Cell(Fd_description)); equ.addCell(new Cell(EQUIPMENT_Num)); equ.addCell(new Cell(EQUIPMENT_Number)); equ.addCell(new Cell(EQUIPMENT_NumSum)); } document.add(equ); document.add(new Paragraph("\n")); Paragraph zhuanjia = new Paragraph("七、到场专家", FontFactory.getFont( FontFactory.HELVETICA_BOLDOBLIQUE, 13, Font.BOLD, new Color(0,0,0))); document.add(zhuanjia); // 设置 Table 表格 Table zhuanj = new Table(1); int zj[] = {20}; zhuanj.setWidths(zj);//设置每列所占比例 zhuanj.setWidth(90); // 占页面宽度 90% zhuanj.setAlignment(Element.ALIGN_CENTER);//居中显示 zhuanj.setAlignment(Element.ALIGN_MIDDLE);//纵向居中显示 zhuanj.setAutoFillEmptyCells(true); //自动填满 zhuanj.setBorderWidth(5); //边框宽度 zhuanj.setBorderColor(new Color(0, 125, 255)); //边框颜色 zhuanj.setPadding(5);//衬距,看效果就知道什么意思了 zhuanj.setSpacing(0);//即单元格之间的间距 zhuanj.setBorder(5);//边框 SelectedExpertServiceImp selectedExpertServiceImp = new SelectedExpertServiceImp(); ExpertInfos expertInfos = selectedExpertServiceImp.getSelectedExpert(FD_OBJECTID, sessionID, userID); ArrayList<ExpertInfo> listexpert = (ArrayList<ExpertInfo>) expertInfos.getExpertInfo(); Iterator<ExpertInfo> itexpert = listexpert.iterator(); String contextexpertString = ""; String chainstring=""; int a=1; if (itexpert.hasNext()) { while (itexpert.hasNext()) { contextexpertString = ""; ExpertInfo expertInfo = (ExpertInfo) itexpert.next(); contextexpertString += a+"."+expertInfo.getEXPERT_NAME() + " (电话:" + expertInfo.getEXPERT_PHONE() +" "+"手机:"+expertInfo.getEXPERT_TEL()+ ")"+"\n"+" "; chainstring+=contextexpertString; a++; } log.info("到场专家:"+chainstring); zhuanj.addCell(new Cell(chainstring)); } else { contextexpertString = "无到场专家!"; zhuanj.addCell(new Cell(contextexpertString)); } document.add(zhuanj); document.add(new Paragraph("\n")); document.close(); } /* * 根据事件id返回转为base64编码的字符串 * @param FD_OBJECTID 事件id * @return 二进制图片转为base64编码格式后的字符串 */ public List<String> getPicStr(String FD_OBJECTID,String contentTempPath){ //获取图片信息 Connection myconn = persistence.getConnection(); Statement stmt = null; InputStream is = null; ResultSet rs = null; String str = ""; List<String> list = new ArrayList<String>(); byte[] Buffer = new byte[1024*300]; try { String sql = "select FILECONTENTS,name,FILEEXT from SysComm_FileImg where mainid='"+FD_OBJECTID+"'"; stmt = myconn.createStatement(); rs = stmt.executeQuery(sql); while (rs.next()) { is = rs.getBinaryStream("FILECONTENTS"); java.io.FileOutputStream long_file = new java.io.FileOutputStream(contentTempPath+"\\"+rs.getString("name")+"."+rs.getString("FILEEXT")); int size = 0; while ((size = is.read(Buffer)) != -1) { long_file.write(Buffer,0,size); long_file.close(); is.close(); } str = contentTempPath+"\\"+rs.getString("name")+"."+rs.getString("FILEEXT"); list.add(str); } } catch (Exception e) { log.error("从数据库取图片发生异常",e); } finally { try { if (rs != null) rs.close(); if (stmt != null) stmt.close(); if (myconn != null) myconn.close(); if (is != null) is.close(); } catch (Exception e) { log.error("关闭数据库连接发生异常",e); } } return list; } public void deletePic(List<String> string){ System.out.println("==============="+string); for(String str:string){ File file = new File(str); file.delete(); } } // public static void main(String[] args) throws Exception { // CreateWord word = new CreateWord(); // String file = "c:/demo1.doc"; // try { // word.createDocContext(file); // } catch (DocumentException e) { // e.printStackTrace(); // } catch (IOException e) { // e.printStackTrace(); // } // // } }
相关推荐
在这个特定的例子中,我们将讨论如何使用Itext来导出Word文档。虽然Itext的主要功能是处理PDF,但通过其扩展库,它也能支持其他格式,包括Microsoft Word的DOC和DOCX格式。 首先,我们来看一下Itext的核心库:`...
在Java开发中,有时我们需要将数据导出为Word文档,以方便阅读和打印。iText是一个流行的库,它允许开发者创建PDF和Word(doc)文件。在这个场景中,我们将探讨如何利用iText来生成包含表格、图片以及带有颜色的文本...
然而,根据你的需求,我们不仅要用iText生成Word文档,还要在文档中嵌入图片,这需要对iText的功能有深入的理解,并且可能需要结合其他库如Apache POI。以下是关于这个主题的详细知识: 1. **iText简介**: iText...
本篇文章将详细讲解如何利用iText库导出Word文档,以及相关的编程知识点。 首先,我们需要了解iText的基本概念。iText是一个开源的Java库,由iText Group NV开发,它允许开发者在Java或.NET环境中生成、修改和处理...
在描述中提到的“导出word文档案例”,我们可以按照以下步骤来实现: 1. **初始化Document对象**:这是iText文档的基础,用于定义文档的结构。 2. **创建Paragraph和Table**:Paragraph用于添加文本,而Table可以...
总结起来,使用iText生成Word文件是一项实用的技能,尤其在需要程序自动化生成报告或文档的场合。通过理解和熟练运用iText,你可以轻松地将数据转换为专业格式的文档,提高工作效率。对于那些需要处理大量文本和格式...
document.add(new Paragraph("这是使用IText生成的PDF文档!")); document.close(); } catch (DocumentException | IOException e) { e.printStackTrace(); } } } ``` 这段代码首先创建了一个`Document`对象...
要开始使用iText生成Word文档,你需要先确保已经添加了iText库到你的项目中。如果是Java项目,可以通过Maven或Gradle来引入依赖。例如,在Maven的pom.xml文件中,你可以添加以下依赖: ```xml <groupId>...
【itext导出Word:创建和操作Word文档的利器】 在IT行业中,处理文档格式转换是常见的需求之一,尤其在企业级应用中。iText是一个强大的开源Java库,专门用于处理PDF文档,但它也提供了创建和操作Word文档(.doc或....
最后,使用iText生成目录,这通常涉及到遍历文档,查找书签并根据标题级别生成相应的目录条目。 2. **设置页码**: 页码的设置可以通过Apache POI直接完成。你可以为每个节(section)设置不同的页码格式,并且...
使用Itext生成Word文档的基本步骤如下: 1. 引入依赖:将上述jar文件添加到项目的类路径中,确保Java程序可以访问到Itext的相关类和方法。 2. 创建Document对象:这是Itext中的基本容器,用于存储文档结构和内容。 ...
根据提供的信息,我们可以总结出以下相关的IT知识点,主要聚焦于使用Java与iText库来实现从Web端将数据库中的数据导出至Word文档的过程。 ### 一、项目背景及技术选型 #### 1. 技术栈简介 - **前端技术**:使用JSF...
本实例将重点讲解如何利用iText来导出Word表格,这对于需要将数据从应用程序导出到可编辑文档的场景非常有用。 首先,我们需要理解iText中的`Document`类是创建PDF或Word文档的基础。在创建Word表格的实例中,我们...
然而,通过一些扩展和技巧,我们也可以使用IText来导出Word文档。在这个过程中,我们将会探讨如何利用IText实现Word文档的各种复杂格式,如层级目录、页眉、页脚、页码设置、字体样式以及包含表格和图片。 1. **...
这通常涉及到先使用iText生成PDF,然后再用第三方工具(如Apache POI)将PDF转换为Word。然而,这种方法可能无法完全保留PDF的所有格式和特性。 **中文字体支持** 在处理中文文档时,iText需要额外的字体资源来...
要使用iText生成Word文档,你需要了解以下关键知识点: 1. **创建PDF文档**:首先,你需要学习如何使用iText创建PDF文档,包括设置页面尺寸、添加文本、图片、表格等元素。这通常涉及到`Document`、`Paragraph`、`...
在这个特定的场景中,我们关注的是如何使用Itext来生成包含图片和表格的Word文档。下面我们将深入探讨这个知识点。 首先,Itext不直接支持创建Word(.doc或.docx)文件,但它可以通过Apache POI库来实现这一功能。...
在提供的链接中,博主分享了一个关于如何使用iText导出Word文档的实际案例。尽管没有具体的代码示例,我们可以根据iText的功能推测实现步骤: 1. **导入依赖**: 首先,项目中需要包含iText库的jar文件,如`itext-...