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. Image for the cookie policy date

Load from stream

Is it possible to load a spreadsheet from an Excel file stream?  What I need to do is to open an Excel file in an .NET web service and add data via an .NET Excel component and then stream it to the Excel viewer without saving it to the server.  Is that possible?

2 Replies

SD Saranya Dhayalan Syncfusion Team January 10, 2020 12:47 PM UTC

Hi William, 
Good day to you. 
We would like to let you know that you can load a Stream into Spreadsheet control by converting the Stream into Formfile and assigning it to File property of OpenRequest of Spreadsheet. We have prepared a sample, in that we have opened a excel to the spreadsheet in ‘created’ event using open method in the client side. Please refer the below code snippets and sample link. 
public IActionResult Open(IFormCollection openRequest) 
            OpenRequest open = new OpenRequest(); 
            MemoryStream memoryStream = new MemoryStream(); 
            openRequest.Files[0].CopyTo(memoryStream); // Excel file is converted into Memory Stream 
            IFormFile formFile = new FormFile(memoryStream, 0, memoryStream.Length, "", openRequest.Files[0].FileName); // converting MemoryStream to IFormFile 
            open.File = formFile; 
            return Content(Workbook.Open(open)); 
  <ejs-spreadsheet ref="spreadsheetRef" openUrl="http://localhost:55367/Home/Open" saveUrl="http://localhost:55367/Home/Save" :created="onCreated"></ejs-spreadsheet> 
import Vue from 'vue'; 
import { SpreadsheetPlugin } from '@syncfusion/ej2-vue-spreadsheet'; 
export default { 
  methods: { 
    onCreated: function() { 
      var request = new XMLHttpRequest(); 
      request.responseType = "blob"; 
      request.onload = () => { 
        var file = new File([request.response], "Sample1.xlsx"); 
        this.$refs.spreadsheetRef.open({ file: file }); 
      request.open("GET", "http://localhost:55367/" + "Sample1.xlsx"); 
Could you please check the above sample and get back to us if you need further assistance on this? 
Saranya D 

WM William Morgenweck February 12, 2020 02:17 AM UTC

This is great.  If I could ask another question,  I don't see in the documentation how I can read each row and change a cell .  I would like the ability to read each row and if column c has a value less than 5 I would change it to another value.  Is that possible?

Live Chat Icon For mobile
Up arrow icon