栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

java:spire.xls导出数据和图片生成excel

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

java:spire.xls导出数据和图片生成excel

第一篇博客

先看效果图

 

上代码,换一下路径就可以直接运行

jar包:spire.xls-4.11.3.jar

//依赖
//		
//		    e-iceblue
//		    spire.xls
//		    4.11.3
//		

public class ExportKBIMG{
	
	private static Logger logger = LoggerFactory.getLogger(ExportKBIMG.class);
	
	
	public static void main(String[] args) throws Exception {
		
		
		Map map;
		List> list = new ArrayList<>();	
		
		for (int column=0; column<5; column++) {
			map = new HashMap();
			
			map.put("0","61607029630"+column);
			map.put("1","背番号"+column);
			map.put("2","车种"+column);
			map.put("3","部品中文名"+column);
			map.put("4","品名"+column);
			map.put("5","受入口"+column);
			map.put("6","收容数"+column);
			map.put("7","C:\Users\htx\Desktop\61214-06220.jpg");
			list.add(map);
		}
		String outputfile = "D:\exportKanBan\看板基础数据.xlsx";
		
		spireExport(list,outputfile);
		
	}

	
	public static void spireExport(List> list,String outputfile)throws Exception {
		//创建Workbook实例 
        Workbook workbook = new Workbook();

        //获取第一张工作表(新建的Workbook默认包含3张工作表)
        Worksheet sheet = workbook.getWorksheets().get(0);
        //为第一张工作表设置名称
        sheet.setName("看板基础数据");
        

        //创建列头单元格样式
        CellStyle style1 = workbook.getStyles().addStyle("Header Style");
        style1.getFont().setSize(12f);
        style1.getFont().setColor(Color.BLACK);
        style1.getFont().isBold(true);
        style1.setHorizontalAlignment(HorizontalAlignType.Center);
        style1.setVerticalAlignment(VerticalAlignType.Center);

        //创建数据单元格样式
        CellStyle style2 = workbook.getStyles().addStyle("Data Style");
        style2.getFont().setSize(10f);
        style2.getFont().setColor(Color.BLACK);
        
      List headlist = Arrays.asList("品番","背番号","车种","部品中文名","品名","受入口","收容数","图片");
      for (int column=0; column 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/642856.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号