Exemple #1
0
        public string HandleCore(List <ExportRequest> request)
        {
            try
            {
                var workbook  = new Workbook();
                var worksheet = workbook.Worksheets[0];

                var xls = new XlsExport();

                int i = 0;
                foreach (var comp in request)
                {
                    switch (comp.Type)
                    {
                    case 1:
                        workbook = xls.KpiToXls(workbook, i);
                        break;
                    }
                    i += 3;
                }

                //     xls.KpiToXls();
            }
            catch (Exception exception)
            {
                Errors = new List <ErrorDto> {
                    new ErrorDto("400", "Unable to export")
                };
            }
            return("");
        }
Exemple #2
0
        public static int Main(string[] args)
        {
            CustomReport customReport = new CustomReport();
            var          objXls       = new XlsExport();

            objXls.FileFormat = FileFormat.Xlsx;

            customReport.Run();
            string strExportFN = string.Format("{0}{1}.xlsx", "C:\\CODE\\Report\\", "Custom Report");

            objXls.Export(customReport.Document, strExportFN);
            return(0);
        }
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Gets exporter object by identificator.
        /// </summary>
        /// <param name="identificator">Export type identificator (name or file extension).</param>
        /// <returns>Unifed document exporter.</returns>
        private static IDocumentExport _GetExporter(string identificator)
        {
            Debug.Assert(!string.IsNullOrEmpty(identificator));

            IDocumentExport export = null;

            // select export format type
            switch (identificator)
            {
            case EXPORT_EXTENSION_HTM:
            case EXPORT_TYPE_NAME_HTM:
                export = new HtmlExport();
                break;

            case EXPORT_EXTENSION_PDF:
            case EXPORT_TYPE_NAME_PDF:
                export = new PdfExport();
                break;

            case EXPORT_EXTENSION_RTF:
            case EXPORT_TYPE_NAME_RTF:
                export = new RtfExport();
                break;

            case EXPORT_EXTENSION_TIF:
            case EXPORT_TYPE_NAME_TIF:
                export = new TiffExport();
                break;

            case EXPORT_EXTENSION_TXT:
            case EXPORT_TYPE_NAME_TXT:
                export = new TextExport();
                break;

            case EXPORT_EXTENSION_XLS:
            case EXPORT_TYPE_NAME_XLS:
                export = new XlsExport();
                break;

            default:
                Debug.Assert(false);     // NOTE: not supported
                break;
            }

            return(export);
        }
Exemple #4
0
        public IActionResult Down([FromQuery] GridRequest request)
        {
            CheckDataSourceParameter();

            var ctx = new RequestContext(SqlScope, SqlId)
                      .SetCmdType(CmdType.query)
                      .SetParam(request)
                      .SetExtraParam(AppCtx.AC.Params);
            var res = AppCtx.Session.QueryPageTable(ctx, request);

            var path = "/pages" + App.GetQuery("path", "");
            var temp = SqlMap.Params.GetValue("ex_tempfile", "temp.xlsx");

            temp = temp.Replace("{tanent}", AppCtx.TenantContext.Tenant.Name);

            var fileName   = SqlMap.Params.GetValue("ex_filename", "down");
            var autoHeight = SqlMap.Params.GetValue("ex_autoheight", false);
            var xls        = new XlsExport(res, App.GetLocalPath(path + temp), autoHeight);

            fileName = App.ReplaceQuery(fileName) + "_" + DateTime.Now.ToYMD() + ".xlsx";
            return(File(xls.Export(), "application/vnd.ms-excel", fileName));
        }
Exemple #5
0
        public void ExecuteReportExcel()
        {
            eReportType reportType;
            ReportBase  activeReport = GetCurrentActiveReport(out reportType);

            if (activeReport != null)
            {
                string reportFilename = Enum.GetName(typeof(eReportType), reportType) + ".xls";

                // Create a memory stream to put the expored XLS into.
                XlsExport    xlsExporter  = new XlsExport();
                MemoryStream outputStream = new MemoryStream();

                // Use the XLS exporter to load the memory stream with the resulting XLS document.
                xlsExporter.Export(activeReport.Document, outputStream);

                // Move the position back to the beginning of the stream.
                outputStream.Seek(0, SeekOrigin.Begin);

                // Create a byte array buffer to read the memory stream into.
                byte[] bytes = new byte[outputStream.Length];
                // Fill the byte array buffer with the bytes from the memory stream.
                outputStream.Read(bytes, 0, (int)outputStream.Length);

                // Clear anything that might have been written by the aspx page.
                HttpContext.Current.Response.ClearContent();
                HttpContext.Current.Response.ClearHeaders();

                //Add the appropriate headers
                HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + reportFilename);
                //Add the right content type
                HttpContext.Current.Response.ContentType = "application/msexcel";

                // Write this report document byte array to the requestor:
                HttpContext.Current.Response.BinaryWrite(bytes);
                // End the response
                HttpContext.Current.Response.End();
            }
        }
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Gets exporter object by identificator.
        /// </summary>
        /// <param name="identificator">Export type identificator (name or file extension).</param>
        /// <returns>Unifed document exporter.</returns>
        private static IDocumentExport _GetExporter(string identificator)
        {
            Debug.Assert(!string.IsNullOrEmpty(identificator));

            IDocumentExport export = null;
            // select export format type
            switch (identificator)
            {
                case EXPORT_EXTENSION_HTM:
                case EXPORT_TYPE_NAME_HTM:
                    export = new HtmlExport();
                    break;

                case EXPORT_EXTENSION_PDF:
                case EXPORT_TYPE_NAME_PDF:
                    export = new PdfExport();
                    break;

                case EXPORT_EXTENSION_RTF:
                case EXPORT_TYPE_NAME_RTF:
                    export = new RtfExport();
                    break;

                case EXPORT_EXTENSION_TIF:
                case EXPORT_TYPE_NAME_TIF:
                    export = new TiffExport();
                    break;

                case EXPORT_EXTENSION_TXT:
                case EXPORT_TYPE_NAME_TXT:
                    export = new TextExport();
                    break;

                case EXPORT_EXTENSION_XLS:
                case EXPORT_TYPE_NAME_XLS:
                    export = new XlsExport();
                    break;

                default:
                    Debug.Assert(false); // NOTE: not supported
                    break;
            }

            return export;
        }