受欢迎的博客标签

WeiXin.Api:Read/Write Excel file in .NET using EPPlus (ASP.NET Core Web Api .NET 5.x)

Published

前言

简介:Epplus是一个使用Open Office XML(Xlsx)文件格式,能读写Excel 2007/2010文件的开源组件
功效:支持对excel文档的汇入汇出,图表(excel自带的图表基本都可以实现)的列印
使用:首先应该下载Epplus的dll文件

github.com上有两个与EPPlus有关的版本。

1.EPPlus

1.1 官网

https://github.com/JanKallman/EPPlus

This repository has been archived by the owner 4 years ago. It is now read-only。

This repository has moved to https://github.com/EPPlusSoftware/EPPlus.

1.2 EPPlus 5  (choiced)

https://github.com/EPPlusSoftware/EPPlus

https://cloud.tencent.com/developer/article/1503632

2.EPPlus.Core  非官方版本

https://github.com/VahidN/EPPlus.Core

EPPlus.Core is an unofficial port of the EPPlus library to .NET Core. This repository has been archived by the owner 3 years ago. It is now read-only.

EPPlus.Core是一个非官方的版本

 

ASP.NET Core Web Api使用EPPlus实现Api导入、导出电子表格Excel,这里使用是EPPlus 5.5.3版本;

 

Prerequisites

 

   OS:ubuntu 18.04-x64

   .Net SDKs: .Net5.x

Non-windows operating systems will requires libgdiplus to be installed. Please use your favorite package manager to install it.

在linux上运行的时候需要安装libgdiplus

apt-get install libgdiplus

output

libgdiplus is already the newest version (4.2-2).

EPPlus samples for .Net 5.x

step 1:Install-Package  EPPlus

首先应该下载Epplus的dll文件,添加dll文件至工程bin文件中。

Install-Package EPPlus

Output

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>

    <PackageReference Include="EPPlus" Version="5.5.3" />

  </ItemGroup>

 </Project>

 

\src\Presentation\WeiXin.Api\WeiXin.Api.csproj

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>

    <PackageReference Include="EPPlus" Version="4.5.3.2" />
    <PackageReference Include="MongoDB.Bson" Version="2.9.2" />
  </ItemGroup>


</Project>

 

step 2:添加引用

using OfficeOpenXml;        
using OfficeOpenXml.Drawing;        
using OfficeOpenXml.Drawing.Chart;        
using OfficeOpenXml.Style;

other excel

一个.NET简单、高效、避免OOM的Excel工具 MiniExcel

 

EPPlus.Core

.Net core Web API+ EPPlus.Core导出数据到Excel

https://www.cnblogs.com/shy-huang/p/9076062.html

ASP.NET Core Web Api+EPPlus 4.5.2.1 Excel导入和导出

https://cloud.tencent.com/developer/article/1503632

EPPlus使用简介

https://www.jianshu.com/p/b7f588ccf26b