Ejemplo n.º 1
0
    public override DevExpress.XtraPrinting.IPrintable CreatePrintableComponent(Item fileItem)
    {
        IWorkbook workbook = new Workbook();

        workbook.AddService(typeof(IChartControllerFactoryService), new ChartControllerFactoryService());
        workbook.AddService(typeof(IChartImageService), new ChartImageService());
        Stream contentStream = DocumentsApp.Data.ReadFileContent(fileItem);

        workbook.LoadDocument(contentStream, GetFormat(fileItem));
        return(workbook);
    }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            #region #ExportToPDF
            Workbook workbook = new Workbook();

            //Register required services.
            workbook.AddService(typeof(IChartControllerFactoryService), new ChartControllerFactoryService());
            workbook.AddService(typeof(IChartImageService), new ChartImageService());

            workbook.LoadDocument("testDocument.xlsx");
            workbook.ExportToPdf("resultingDocument.pdf");
            #endregion #ExportToPDF
            System.Diagnostics.Process.Start("resultingDocument.pdf");
        }
Ejemplo n.º 3
0
    IBasePrintable CreatePrintableComponent(string extention, Stream contentStream)
    {
        IBasePrintable component;

        if (RICH_EDIT_TYPES.Contains(extention))
        {
            RichEditDocumentServer docServer = new RichEditDocumentServer();
            switch (extention)
            {
            case ".docx": docServer.LoadDocument(contentStream, DevExpress.XtraRichEdit.DocumentFormat.Doc); break;

            case ".doc": docServer.LoadDocument(contentStream, DevExpress.XtraRichEdit.DocumentFormat.Doc); break;

            case ".rtf": docServer.LoadDocument(contentStream, DevExpress.XtraRichEdit.DocumentFormat.Rtf); break;

            case ".html": docServer.LoadDocument(contentStream, DevExpress.XtraRichEdit.DocumentFormat.Html); break;
            }
            component = docServer;
        }
        else if (SPREAD_SHEET_TYPES.Contains(extention))
        {
            IWorkbook workbook = new Workbook();
            workbook.AddService(typeof(IChartControllerFactoryService), new ChartControllerFactoryService());
            workbook.AddService(typeof(IChartImageService), new ChartImageService());
            switch (extention)
            {
            case ".xls": workbook.LoadDocument(contentStream, DevExpress.Spreadsheet.DocumentFormat.Xls); break;

            case ".xlsx": workbook.LoadDocument(contentStream, DevExpress.Spreadsheet.DocumentFormat.Xlsx); break;

            case ".txt": workbook.LoadDocument(contentStream, DevExpress.Spreadsheet.DocumentFormat.Text); break;

            case ".csv": workbook.LoadDocument(contentStream, DevExpress.Spreadsheet.DocumentFormat.Csv); break;
            }
            component = workbook;
        }
        else
        {
            return(null);
        }
        return(component);
    }
Ejemplo n.º 4
0
        void ProcessExcel(string fileName, List <KeyValuePair <int, int> > data)
        {
            //fileName = @"C:\Users\Mushfikur Rahman\Downloads\Technical-Adaptive Assessment.xlsx";

            //Microsoft.Office.Interop.Excel.Application excelAppObj = new Microsoft.Office.Interop.Excel.Application();
            //excelAppObj.DisplayAlerts = false;

            //Open the excel work book
            //Microsoft.Office.Interop.Excel.Workbook workBook = excelAppObj.Workbooks.Open(fileName, 0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, 0, false, false);

            //ExcelWorkbook workBook = ExcelWorkbook.ReadXLSX(fileName);


            //Get the first sheet of the selected work book
            //Microsoft.Office.Interop.Excel.Worksheet worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workBook.Worksheets.get_Item(1);
            //var worksheet = workBook.Worksheets[0];

            //Book workbook = new BinBook();
            //workbook.load(fileName);
            Workbook workbook = new Workbook();

            workbook.LoadDocument(fileName);

            //var worksheet = workbook.getSheet(0);
            var worksheet = workbook.Worksheets[0];

            //Write 20 in Cell - C3
            worksheet.Cells[4, 3].Value   = txtName.Text;
            worksheet.Cells[186, 1].Value = txtCompany.Text + ", " + txtEmail.Text;

            //worksheet.writeStr(5, 4, txtName.Text);
            //worksheet.writeStr(187, 2, txtCompany.Text + ", " + txtEmail.Text);

            var curRow = 6;

            foreach (var item in data)
            {
                worksheet.Cells[curRow + item.Key - 1, 3].Value   = 1;
                worksheet.Cells[curRow + item.Value - 1, 4].Value = 1;

                //worksheet.writeNum(curRow + item.Key - 1, 4, 1);
                //worksheet.writeNum(curRow + item.Value - 1, 5, 1);

                curRow += 4;
            }

            //Save work book (.xlsx format)
            //workBook.SaveAs(fileName, Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook, null, null, false,
            //false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlShared, false, false, null, null, null);
            //workBook.WriteXLSX(fileName);
            //workbook.save(fileName);

            //excelAppObj.Quit();
            workbook.AddService(typeof(IChartControllerFactoryService), new ChartControllerFactoryService());
            workbook.AddService(typeof(IChartImageService), new ChartImageService());


            workbook.SaveDocument(fileName);
            var pdfFileName = fileName.Replace(".xlsx", ".pdf");

            workbook.ExportToPdf(pdfFileName);
            Session["ReportFilePath"] = pdfFileName;

            var reportID = ins.SaveDownloads(int.Parse(Session["userId"].ToString()), "Natural Ability", pdfFileName);

            Session["ReportID"] = reportID;

            string errorFileName = Server.MapPath("~") + @"\Files\Docx\EmailError.txt";

            var res         = 1;// Basics.email_send(fileName.Replace(".xlsx", ".pdf"), string.Format("Natural Ability Assessment  - {0}-{1}", txtName.Text, txtCompany.Text), "Your assessment report is ready to download.", txtEmail.Text, errorFileName);
            var CurrentPage = GetCurrentPageName();

            ins.DeleteHolt(int.Parse(Session["userId"].ToString()), CurrentPage);
            ins.DeleteAnsState(CurrentPage, int.Parse(Session["userId"].ToString()));
            if (res == 1)
            {
                Response.Redirect("Home.aspx");
            }
            else
            {
                Response.Redirect("Error.aspx");
            }
        }