We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Unrecognized SaveAsActionResult method.

Thread ID:

Created:

Updated:

Platform:

Replies:

125064 Jul 19,2016 08:56 AM UTC Jul 20,2016 08:56 AM UTC ASP.NET MVC 1
loading
Tags: XlsIO
CLAUDIO RICCARDI
Asked On July 19, 2016 08:56 AM UTC

Hi,

I'm trying to use the following code snippet provided as sample to write data on Excel file.

<<
        public ActionResult GenerateXLS(string SaveOption)
        {
            if (SaveOption == null)
                return View();

            //New instance of XlsIO is created.[Equivalent to launching Microsoft Excel with no workbooks open].
            //The instantiation process consists of two steps.

            //Step 1 : Instantiate the spreadsheet creation engine.
            ExcelEngine excelEngine = new ExcelEngine();
            //Step 2 : Instantiate the excel application object.
            IApplication application = excelEngine.Excel;

            //A new workbook is created.[Equivalent to creating a new workbook in Microsoft Excel]
            //The new workbook will have 12 worksheets
            IWorkbook workbook = application.Workbooks.Open(DefaultResolveApplicationDataPath(@"QuotePreview.xls"));

            IWorksheet sheet = workbook.Worksheets[1];
            sheet.FirstVisibleRow = 3;

            IFont font = workbook.CreateFont();
            font.Bold = true;

           ...

            try
            {
                //Saving the workbook to disk.
                if (SaveOption == "Xls")
                {
                    //Save as .xls format
                    return excelEngine.SaveAsActionResult(workbook, "Quote1.xls", HttpContext.ApplicationInstance.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel97);
                }
                //Save as .xlsx format
                else
                {
                    workbook.Version = ExcelVersion.Excel2013;
                    return excelEngine.SaveAsActionResult(workbook, "Quote1.xlsx", HttpContext.ApplicationInstance.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel2013);
                }
            }
            catch (Exception)
            {
            }

            //Close the workbook.
            workbook.Close();
            excelEngine.Dispose();
            return View();
        }

        private string DefaultResolveApplicationDataPath(string fileName)
        {
            //string dataPath = string.Format("{0}\\Common\\Data\\XlsIO\\", Request.PhysicalPath.ToLower().Split(new string[] { "\\XlsIO" }, StringSplitOptions.None));
            //return string.Format("{0}\\{1}", dataPath, fileName);

            string folderName = "Data\\XlsIO";
            string dataPath = new System.IO.DirectoryInfo(Request.PhysicalPath + "..\\..\\..\\..\\..\\Common").FullName;
            if (folderName != string.Empty)
                dataPath += "\\" + folderName;
            return string.Format("{0}\\{1}", dataPath, fileName);
        }

When I compile, I get the error message Unable to find method SaveAsActionResult for ExcelEngine object.
Must I define an extension as explained in http://help.syncfusion.com/file-formats/xlsio/asp-net-mvc?

Can you help me?

Thanks


Sridhar Sukumar [Syncfusion]
Replied On July 20, 2016 08:56 AM UTC

Hi Claudio, 
 
Thank you for contacting Syncfusion support. 
 
When I compile, I get the error message Unable to find method SaveAsActionResult for ExcelEngine object. 
 
 
Must I define an extension as explained in http://help.syncfusion.com/file-formats/xlsio/asp-net-mvc? 
Yes, you need to define an extension. 
 
We have prepared a simple sample for using XlsIO in ASP.NET MVC application which can be downloaded from the following link 
 
 
Alternative way: 
 
If you install Nuget package for ASP.NET MVC, then you no need to define the extension for those methods. The Nuget package for ASP.NET MVC can be downloaded from the following link: 
 
Download link: 
 
 
Regards, 
Sridhar S 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;