简体   繁体   English

我无法交换文件。 从XLS到XLSX

[英]I am having trouble swapping a file. From XLS to XLSX

I'm trying to make a change in the application code, because I've tried it anyway and I'm not having success. 我正在尝试对应用程序代码进行更改,因为无论如何我已经尝试过了,但我没有成功。 I have a reporting tab on my system, but it is only exporting XLS files and I need to switch to XLSX because the XLS is limited to 65,000 lines. 我的系统上有一个报告选项卡,但它只导出XLS文件,我需要切换到XLSX,因为XLS限制为65,000行。 I'll show a part of my controler when he's mounting the XLS. 当他安装XLS时,我会展示我的控制器的一部分。 I can not show my Service method because it is VERY large and you would be kind of lost. 我无法显示我的服务方法,因为它非常大而且你会丢失。

[CustomAuthorize(TipoFuncao.PRINT)]
public ActionResult Index(FiltroRptManifesto filtro)
{
    byte[] result = null;
    bool overflowMonth = false;
    IWorkbook workbook = new XSSFWorkbook();

    try
    {                
        RptManifestoService rptManifestoService = new RptManifestoService(ModelState);
        result = rptManifestoService.GeraExcel(Server.MapPath("~/Content/RptManifesto.xls"), filtro, ViewBag.Usuario);
        if (ModelState.IsValid)
        {
             if (ValidateDate(ModelState["DtProtocoloIni"].Value, ModelState["DtProtocoloFin"].Value).Days > 540)
             {
                 overflowMonth = true;
                 throw new Exception();
             };

             Response.AppendCookie(new HttpCookie("downloadToken", filtro.DownloadToken));                                    
             return File(result, "application/vnd.ms-excel", "Manifesto.xls");
        }
    }
//...

I've never used NPOI so I may be wrong but what happens if you do: 我从来没有使用过NPOI所以我可能错了,但如果你这样做会发生什么:

var fileName = "Manifesto.xlsx";
return File(result, MimeMapping.GetMimeMapping(fileName), fileName);

or 要么

return File(
        result, 
        "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", 
        "Manifesto.xlsx");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM