Instead of downloading existing excel file , needs to preview

Hi,

I am using asp.net core 1.1.2 version and I like to use Syncfusion to document preview.  I have tried many times to preview documents in syncfusion, but instead of previewing its downloading.
So I need to preview existing excel file from wwwroot directory instead of download . Is it possible  to do using syncfusion?.

Please help me..

Thanks,

Regards,
Rikasa

3 Replies

SI Silambarasan I Syncfusion Team November 6, 2017 09:38 AM UTC

Hi Rikasa, 
 
Thank you for using Syncfusion products. 
 
We have checked your reported query and prepared a sample to demonstrate your requirement ‘To import excel file form wwwroot directory in Spreadsheet’ by using ‘import-on-load’ property. Please refer the below code example. 
CS 
 
public class HomeController : Controller 
{ 
    private IHostingEnvironment _env; 
    public HomeController(IHostingEnvironment env) 
    { 
        _env = env; 
    } 
    public IActionResult Index() 
    { 
        return View(); 
    } 
    public string Import(ImportRequest importRequest) 
    { 
        if (importRequest.File == null) 
        { 
            string basePath = _env.WebRootPath + @"\Files\sample.xlsx"; 
            FileStream fStream = new FileStream(basePath, FileMode.Open); 
            importRequest.FileStream = fStream; 
            var spreadsheetData = Spreadsheet.Open(importRequest); 
            fStream.Dispose(); 
            return spreadsheetData; 
        } 
        else 
            return Spreadsheet.Open(importRequest); 
    } 
} 
 
 
CSHTML 
 
<ej-spread-sheet id="Spreadsheet"> 
    <e-import-settings import-on-load="true" import-mapper="Home/Import"></e-import-settings> 
    //... 
</ej-spread-sheet> 
 
 
 
Could you please check the above sample and get back to us if we misunderstood your requirement or if you need any further assistance on this. 
 
Regards, 
Silambarasan 



RI Rikasa November 7, 2017 06:11 AM UTC

Hi Silambarasan ,

Thank you for reply.

I will check and let you.

Thank you.

Regards,

Rikasa



SI Silambarasan I Syncfusion Team November 8, 2017 05:11 AM UTC

Hi Rikasa, 
 
Thanks for your update. We will wait to hear from you.  
 
Regards, 
Silambarasan 


Loader.
Up arrow icon