java向excel写数据
package pymongo1;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;
public class out_put {
// String device_name;
// String MacDevice_mip;
// String Interface_name;
// String TopoLink_dataFlag;
// String device2_name;
// String MacDevice2_mip;
// String Media_uniName;
// String path;
//
// public int j;
// public int k;
public void out_put(){}
public static void out1(databean data,String path,int k,int j) throws IOException, RowsExceededException, WriteException
{
String device_name=data.device_name;
String MacDevice_mip=data.MacDevice_mip;
String Interface_name=data.Interface_name;
String TopoLink_dataFlag=data.TopoLink_dataFlag;
String device2_name=data.device2_name;
String MacDevice2_mip=data.MacDevice2_mip;
String Media_uniName=data.Media_uniName;
//创建工作薄
File file=new File(path);
if(!file.exists())
{
file.createNewFile();
}
WritableWorkbook workbook = Workbook.createWorkbook(file);
//创建新的一页
WritableSheet sheet = workbook.createSheet("NG7.0topo",0);
//创建要显示的内容,创建一个单元格,第一个参数为列坐标,第二个参数为行坐标,第三个参数为内容
if (k==0){
Label column1 = new Label(0,0,"device_name");
sheet.addCell(column1);
Label column2 = new Label(1,0,"MacDevice_mip");
sheet.addCell(column2);
Label column3 = new Label(2,0,"Interface_name");
sheet.addCell(column3);
Label column4 = new Label(3,0,"TopoLink_dataFlag");
sheet.addCell(column4);
Label column5 = new Label(4,0,"device2_name");
sheet.addCell(column5);
Label column6 = new Label(5,0,"MacDevice2_mip");
sheet.addCell(column6);
Label column7 = new Label(6,0,"Media_uniName");
sheet.addCell(column7);
k++;
}
// 心累 没想到输出excel竟然是个大坑 。。。。。。。。。。。。。
int i=0;
Label column11 = new Label(i,j,device_name);
sheet.addCell(column11);
System.out.println(i);
System.out.println(device_name);
i++;
Label column21 = new Label(i,j,MacDevice_mip);
sheet.addCell(column21);
i++;
Label column31 = new Label(i,j,Interface_name);
sheet.addCell(column31);
i++;
Label column41 = new Label(i,j,TopoLink_dataFlag);
sheet.addCell(column41);
i++;
Label column51 = new Label(i,j,device2_name);
sheet.addCell(column51);
i++;
Label column61 = new Label(i,j,MacDevice2_mip);
sheet.addCell(column61);
i++;
Label column71 = new Label(i,j,Media_uniName);
sheet.addCell(column71);
j++;
System.out.println(i);
System.out.println(j);
workbook.write();
workbook.close();
}
}
最新文章
- js像素运算问题
- 单例模式双重检查锁(DCL)问题
- PHP+Nginx环境搭配
- poj1039Pipe(直线交点、叉积)
- django笔记
- Android Service 简介
- sha加密算法
- mysql主从同步(4)-Slave延迟状态监控
- Codeforces Round 1153(div. 2)
- xcode9.4 报错 error:The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
- 微信H5开发,页面被缓存,不更新
- MVC 中Scripts.Render、Styles.Render
- [No0000192]Vim打开和保存文件-Vim使用技巧(7)
- 【转】学习Linux守护进程详细笔记
- flask基础之请求钩子(十二)
- 递归遍历嵌套结构(多层List)中的元素 ------Python
- Alpha发布——美工+文案展示博客
- HDU 4300 Clairewd’s message(KMP+思维)
- Commons包详解
- 解决";hibernate.hbm2ddl.auto"; update值 无效
热门文章
- iOS KVC 和 KVO 的学习
- 【Tech】单点登录系统CAS客户端demo
- 【HackerRank】QuickSort(稳定快排,空间复杂度O(n))
- [GUI] Linux中的图形管理
- 主攻ASP.NET.4.5.1 MVC5.0之重生:Web项目语音朗读网页文本,简单语音提示浏览状态
- 前端自动化构建工具-gulp
- Bootstrap3组件--2
- c#.NET中日志信息写入Windows日志中解决方案
- UVA 11731 Ex-circles (外切圆)
- dom 兼容性问题1_节点部分