You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.7 KiB
C#
55 lines
1.7 KiB
C#
using DS.Module.Core;
|
|
using DS.Module.ExcelModule;
|
|
using DS.Module.ExcelModule.Model;
|
|
using DS.WMS.Core.Code.Interface;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace DS.WMS.MainApi.Controllers
|
|
{
|
|
/// <summary>
|
|
/// Excel服务 模块
|
|
/// </summary>
|
|
public class ExcelController : ApiController
|
|
{
|
|
private readonly IExcelService _invokeService;
|
|
|
|
/// <summary>
|
|
/// 构造函数
|
|
/// </summary>
|
|
/// <param name="invokeService"></param>
|
|
public ExcelController(IExcelService invokeService)
|
|
{
|
|
_invokeService = invokeService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据用户列导出Excel数据
|
|
/// </summary>
|
|
/// <param name="req">请求数据</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("ExportExcelByColumn")]
|
|
public DataResult<string> ExportExcelByColumn([FromBody] ExportByColumnReq req)
|
|
{
|
|
return _invokeService.ExportExcelByColumn(req);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据用户列导出Excel文件流
|
|
/// </summary>
|
|
/// <param name="req">请求数据</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[Route("ExportExcelStreamByColumn")]
|
|
public IActionResult ExportExcelStreamByColumn([FromBody] ExportByColumnReq req)
|
|
{
|
|
var result = _invokeService.ExportExcelStreamByColumn(req);
|
|
HttpContext.Response.Headers.Add("Content-Length", result.Length.ToString());
|
|
HttpContext.Response.Headers.Add("Content-Type", "charset=UTF-8");
|
|
return File(result, "application/octet-stream;charset=UTF-8", Path.GetFileName(Path.GetRandomFileName() + ".xlsx"));
|
|
|
|
}
|
|
}
|
|
}
|