0

我编写了一个简单的控制台程序(在 C# 中),它生成一个 PowerPoint 演示文稿,但我需要能够通过基于 SharePoint 页面的 asp.net 表单设置对象(文本、图片等),目前这可以在任何地方保存演示文稿我也告诉它,但我要求它作为用户从 SharePoint 下载输出。我正在寻找有关如何做这样的事情的任何指示。我了解表单和请求参数等的使用,但不确定如何让程序在服务器端运行并输出可下载文件。

任何帮助,非常感谢。

我会发布一些代码,但我对 ASP 很陌生,所以这是对我如何去做这样的事情的大量研究。据我所知,我必须从 SharePoint 列表中填充表单。

4

1 回答 1

0

您可以直接在您的 asp.net WebApp 上执行此操作。像这样:

            ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Pos Venda");

            #region tabelaPrincipal

            worksheet.Cells[1, 1, 1, 9].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
            worksheet.Cells[1, 1, 1, 9].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.FromArgb(149, 179, 215));
            worksheet.Cells[1, 1, 1, 9].Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Medium, System.Drawing.Color.Black);

            worksheet.Cells[1, 1].Value = "N. O.S.";
            worksheet.Cells[1, 2].Value = "DATA";
            worksheet.Cells[1, 3].Value = "TECNICO";
            worksheet.Cells[1, 4].Value = "TEMPO";
            worksheet.Cells[1, 5].Value = "ATIVIDADE";
            worksheet.Cells[1, 6].Value = "COMO";
            worksheet.Cells[1, 7].Value = "EMPRESA";
            worksheet.Cells[1, 8].Value = "VALOR";
            worksheet.Cells[1, 9].Value = "SITUACAO";
            package.Workbook.Properties.Title = "Relatório de Pós Venda";
            package.Workbook.Properties.Author = "SGP";
            package.Workbook.Properties.Company = "Libracom Automação Industrial Ltda.";

            Response.Clear();
            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "application/x-msexcel";
            Response.AddHeader("Content-Disposition", String.Format("attachment;filename=\"{0}\"", "Relatorio" + DateTime.Now.ToString("ddMMyyyyHHmmss") + ".xlsx"));
            Response.BinaryWrite(package.GetAsByteArray());
            Response.Flush();
            Response.SuppressContent = true;
            ApplicationInstance.CompleteRequest();
            Response.End();

@edit:使用 EPPlus DLL。http://epplus.codeplex.com/

于 2013-11-14T11:26:56.303 回答