网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
07月02日漏签0天
人工智能编程吧 关注:30,877贴子:466,082
  • 看贴

  • 图片

  • 吧主推荐

  • 视频

  • 游戏

  • 10回复贴,共1页
<<返回人工智能编程吧
>0< 加载中...

Java写的电话号码本自动化生成器,程序片段

  • 只看楼主
  • 收藏

  • 回复
  • hello123401
  • 大凡金属
    6
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
最近在做一个小玩意儿,姑且名之为《电话号码本自动化生成器》。 功能就是把各单位送来的电话号码表上传到服务器,服务器把这些Excel解析成许多Item对象,然后将对象列表序列化到文件中,之后在合适的机会反序列化所有对象,参照Excel模板生成汇总后的电话号码本。
一直用业余时间断断续续地写,拖了太长时间,现在代码的质量已经没法控制了,也懒得去把代码改得漂亮了。作为apache poi的应用实例倒是还不错。



  • 人工智能编程1
  • 大凡金属
    12
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
可以发到10262790,再发个链接出来就行了。10262790从来不会删帖的!


2025-07-02 14:36:32
广告
  • hello123401
  • 大凡金属
    6
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
HashMap<RowType,ArrayList<CellStyle>> tempH=this.LoadStyleFromTemplet(tempW);//从模板中拷贝样式到工作簿,要修改样式只需修改模版即可
ArrayList<String> tempSL=this.getDepartmentList();//从文件中读取单位列表数据
//准备好数据和样式,开始填充
int rc=0;//行游标
for(String s:tempSL){
ArrayList<Item> tempIL=this.getItemsInDepartment(s);//
/******/
Row tempR=tempST.createRow(rc++);//新建标题行-单位名称
if(s.length()>"区委区委区委区委区委区委区委区委区委区".length())
tempR.setHeightInPoints(30);
else tempR.setHeightInPoints(18);
Cell tempC=tempR.createCell(0);
tempC.setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(1).setCellValue(s);
tempR.createCell(2).setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(3).setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(4).setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(5).setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(6).setCellType(Cell.CELL_TYPE_BLANK);
for(Cell c:tempR){//应用样式
c.setCellStyle(tempH.get(RowType.HEAD).get(c.getColumnIndex()));
}
tempST.addMergedRegion(new CellRangeAddress(rc-1, rc-1,1,6));//合并单元格
/*****/
/*******************************************/
tempR=tempST.createRow(rc++);//新建标题行-个人头部
tempR.setHeightInPoints(15);
tempC=tempR.createCell(0);
tempC.setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(1).setCellValue("姓 名");
tempR.createCell(2).setCellValue("职 务");
tempR.createCell(3).setCellValue("办公电话");
tempR.createCell(4).setCellValue("内码");
tempR.createCell(5).setCellValue("住宅电话");
tempR.createCell(6).setCellValue("移动电话");
for(Cell c:tempR){
c.setCellStyle(tempH.get(RowType.HEAD_PERSONAL).get(c.getColumnIndex()));
}
/***********************************************/
for(Item i:tempIL){//处理Personalitem
if(i.isPersonalItem()){
PersonalItem tempPIT=(PersonalItem)i;
// String tempS=this.generateTitle(tempPIT.Title);
// String[] tempSS=tempS.split("\n");
// int tempLC=tempSS.length;
float tempRowHeight=this.calcuRowHeight(tempPIT.OfficePhone.size(), this.calcuTextLines(this.generateTitle(tempPIT.Title,this.getMaxTitleLength(6))), 14.25f);
int tempMaxTL=this.getMaxTitleLength(0);
if(tempPIT.OfficePhone.size()>1){
for(int j=0;j<tempPIT.OfficePhone.size();j++){//新建多行,一般情况下最多两行
tempR=tempST.createRow(rc++);//新建一行
// float tempLH=13*tempLC/tempPIT.OfficePhone.size();
if(j==0){//除了办公电话和内码每行写一条外,其它信息都写在第一行
// String tempS=this.generateTitle(tempPIT.Title);
tempR.setHeightInPoints(tempRowHeight);
tempC=tempR.createCell(0);
tempC.setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(1).setCellValue(this.generateName(tempPIT.getName()));
tempR.createCell(2).setCellValue(this.generateTitle(tempPIT.Title,tempMaxTL));
tempR.createCell(3).setCellValue(tempPIT.OfficePhone.get(j).getLongNumber());



  • hello123401
  • 大凡金属
    6
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
tempR.createCell(4).setCellValue(tempPIT.OfficePhone.get(j).getShortNumber());
tempR.createCell(5).setCellValue(tempPIT.getHomePhone());
tempR.createCell(6).setCellValue(tempPIT.getMobilePhone());
}else{
tempR.setHeightInPoints(tempRowHeight);
tempC=tempR.createCell(0);
tempC.setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(1).setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(2).setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(3).setCellValue(tempPIT.OfficePhone.get(j).getLongNumber());
tempR.createCell(4).setCellValue(tempPIT.OfficePhone.get(j).getShortNumber());
tempR.createCell(5).setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(6).setCellType(Cell.CELL_TYPE_BLANK);
}
for(Cell c:tempR){//应用样式
c.setCellStyle(tempH.get(RowType.PERSONAL).get(c.getColumnIndex()));
}
}
tempST.addMergedRegion(new CellRangeAddress(rc-tempPIT.OfficePhone.size(), rc-1,1,1));//合并单元格
tempST.addMergedRegion(new CellRangeAddress(rc-tempPIT.OfficePhone.size(), rc-1,2,2));
tempST.addMergedRegion(new CellRangeAddress(rc-tempPIT.OfficePhone.size(), rc-1,5,5));
tempST.addMergedRegion(new CellRangeAddress(rc-tempPIT.OfficePhone.size(), rc-1,6,6));
}else{
tempR=tempST.createRow(rc++);//新建一行
// float tempLHSL=(tempLC==1)?14.25f:13f*tempLC;
tempR.setHeightInPoints(tempRowHeight);
tempC=tempR.createCell(0);
tempC.setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(1).setCellValue(this.generateName(tempPIT.getName()));
tempR.createCell(2).setCellValue(this.generateTitle(tempPIT.Title,tempMaxTL));
tempR.createCell(3).setCellValue(tempPIT.OfficePhone.get(0).getLongNumber());
tempR.createCell(4).setCellValue(tempPIT.OfficePhone.get(0).getShortNumber());
tempR.createCell(5).setCellValue(tempPIT.getHomePhone());
tempR.createCell(6).setCellValue(tempPIT.getMobilePhone());
for(Cell c:tempR){//应用样式
c.setCellStyle(tempH.get(RowType.PERSONAL).get(c.getColumnIndex()));
}
}
}else{
break;//遇到第一个非PersonalItem,退出循环
}
}
/*********************************************/
tempR=tempST.createRow(rc++);//新建标题行-单位头部
tempR.setHeightInPoints(15);
tempC=tempR.createCell(0);
tempC.setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(1).setCellValue("名 称");
tempR.createCell(2).setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(3).setCellValue("办公电话");
tempR.createCell(4).setCellValue("内码");
tempR.createCell(5).setCellValue("备注");
tempR.createCell(6).setCellType(Cell.CELL_TYPE_BLANK);
for(Cell c:tempR){
c.setCellStyle(tempH.get(RowType.HEAD_DEPARTMENT).get(c.getColumnIndex()));
}
tempST.addMergedRegion(new CellRangeAddress(rc-1, rc-1,1,2));
tempST.addMergedRegion(new CellRangeAddress(rc-1, rc-1,5,6));
/*************************************************/
for(Item i:tempIL){//处理OrgItem
if(i.isPersonalItem()){
continue;//跳过所有PersonalItem



  • hello123401
  • 大凡金属
    6
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
}else{
OrgItem tempOIT=(OrgItem)i;
// float tempRowHeight=this.calcuRowHeight(tempOIT.OfficePhone.size(),tempOIT.OfficePhone.size(), 14.25f);
if(tempOIT.OfficePhone.size()>1){
for(int j=0;j<tempOIT.OfficePhone.size();j++){//新建多行,一般情况下最多两行
tempR=tempST.createRow(rc++);//新建一行
// float tempLH=13*tempLC/tempPIT.OfficePhone.size();
if(j==0){//除了办公电话和内码每行写一条外,其它信息都写在第一行
// String tempS=this.generateTitle(tempPIT.Title);
tempR.setHeightInPoints(10.25f);
tempC=tempR.createCell(0);
tempC.setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(1).setCellValue(this.generateName(tempOIT.getName()));
tempR.createCell(2).setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(3).setCellValue(tempOIT.OfficePhone.get(j).getLongNumber());
tempR.createCell(4).setCellValue(tempOIT.OfficePhone.get(j).getShortNumber());
tempR.createCell(5).setCellValue(tempOIT.OfficePhone.get(j).getMemo());
tempR.createCell(6).setCellType(Cell.CELL_TYPE_BLANK);
}else{
tempR.setHeightInPoints(10.25f);
tempC=tempR.createCell(0);
tempC.setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(1).setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(2).setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(3).setCellValue(tempOIT.OfficePhone.get(j).getLongNumber());
tempR.createCell(4).setCellValue(tempOIT.OfficePhone.get(j).getShortNumber());
tempR.createCell(5).setCellValue(tempOIT.OfficePhone.get(j).getMemo());
tempR.createCell(6).setCellType(Cell.CELL_TYPE_BLANK);
}
for(Cell c:tempR){//应用样式
c.setCellStyle(tempH.get(RowType.DEPARTMENT).get(c.getColumnIndex()));
}
}
tempST.addMergedRegion(new CellRangeAddress(rc-tempOIT.OfficePhone.size(), rc-1,1,2));//合并单元格
//tempST.addMergedRegion(new CellRangeAddress(rc-tempOIT.OfficePhone.size(), rc-1,2,2));
//tempST.addMergedRegion(new CellRangeAddress(rc-tempOIT.OfficePhone.size(), rc-1,5,5));
tempST.addMergedRegion(new CellRangeAddress(rc-tempOIT.OfficePhone.size(), rc-1,5,6));
}else{
tempR=tempST.createRow(rc++);//新建一行
// float tempLHSL=(tempLC==1)?14.25f:13f*tempLC;
tempR.setHeightInPoints(tempOIT.OfficePhone.get(0).getMemo().length()==0?14.25f:25f);
tempC=tempR.createCell(0);
tempC.setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(1).setCellValue(this.generateName(tempOIT.getName()));
tempR.createCell(2).setCellType(Cell.CELL_TYPE_BLANK);
tempR.createCell(3).setCellValue(tempOIT.OfficePhone.get(0).getLongNumber());
tempR.createCell(4).setCellValue(tempOIT.OfficePhone.get(0).getShortNumber());
tempR.createCell(5).setCellValue(tempOIT.OfficePhone.get(0).getMemo());
tempR.createCell(6).setCellType(Cell.CELL_TYPE_BLANK);
for(Cell c:tempR){//应用样式
c.setCellStyle(tempH.get(RowType.DEPARTMENT).get(c.getColumnIndex()));
}
tempST.addMergedRegion(new CellRangeAddress(rc-1, rc-1,1,2));
tempST.addMergedRegion(new CellRangeAddress(rc-1, rc-1,5,6));



  • 凌烟阁主人
  • 大凡金属
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
楼主这个代码是全的吗


  • 无聊的菜虫
  • 大凡金属
    10
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
现在代码的质量已经没法控制了,也懒得去把代码改得漂亮了。
说明你的组织能力不够


  • 一朵无名之花
  • 大凡金属
    13
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
可以啊


2025-07-02 14:30:32
广告
  • friday5pm
  • 大凡金属
    2
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
这个里面有人工智能吗?


  • 中国风CLTC
  • 大凡金属
    11
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
辛苦辛苦


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 10回复贴,共1页
<<返回人工智能编程吧
分享到:
©2025 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示