zoukankan      html  css  js  c++  java
  • NPOI Mapper导出Excel

    .NET FrameWork

    返回对象

    HttpResponseMessage

    测试

    List<ImportExcel_Model> students = new List<ImportExcel_Model>
    {
    new ImportExcel_Model{ name="夫子",email="15153989759@qq.com",mobile_phone="15053989759" },
    new ImportExcel_Model{ name="余帘",email="15153989759@qq.com",mobile_phone="151539459759" },
    new ImportExcel_Model{ name="李慢慢",email="15153989759@qq.com",mobile_phone="15153989459" },
    };

    var mapper = new Mapper();
    MemoryStream stream = new MemoryStream();
    mapper.Save(stream, students, "sheet1", overwrite: true, xlsx: true);
    return new HttpResponseMessage { Content = new ByteArrayContent(stream.ToArray()) };

    Core

    返回对象

    ActionResult

    实现

    List<ImportExcel_Model> students = new List<ImportExcel_Model>
    {
    new ImportExcel_Model{ name="夫子",email="15153989759@qq.com",mobile_phone="15150989759" },
    new ImportExcel_Model{ name="余帘",email="15153989759@qq.com",mobile_phone="15152989759" },
    new ImportExcel_Model{ name="李慢慢",email="15153989759@qq.com",mobile_phone="15153989739" },
    };

    var mapper = new Mapper();
    MemoryStream stream = new MemoryStream();
    mapper.Save(stream, students, "sheet1", overwrite: true, xlsx: true);
    return File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Demo.xlsx");

  • 相关阅读:
    <Redis> 入门六 主从复制方式的集群
    <Redis> 入门五 持久化RBD/AOF
    <Redis> 入门四 Jedis操作Redis
    <Redis> 入门三 事务
    <Redis> 入门X 分布式锁
    <Redis> 入门二 五种数据类型的操作、通用key的操作、发布订阅
    <Redis> 入门一 概念安装
    <Linux> 下安装和卸载JDK
    <ActiveMQ>
    <linux>入门
  • 原文地址:https://www.cnblogs.com/cdjbolg/p/15464696.html
Copyright © 2011-2022 走看看