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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Load from stream

Thread ID:

Created:

Updated:

Platform:

Replies:

150513 Jan 9,2020 12:02 PM UTC Feb 12,2020 02:17 AM UTC Vue 2
loading
Tags: Spreadsheet
William Morgenweck
Asked On January 9, 2020 12:02 PM UTC

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?

Saranya Dhayalan [Syncfusion]
Replied On 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. 
 
HomeController.cs 
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)); 
        } 
 
App.vue 
<template> 
  <ejs-spreadsheet ref="spreadsheetRef" openUrl="http://localhost:55367/Home/Open" saveUrl="http://localhost:55367/Home/Save" :created="onCreated"></ejs-spreadsheet> 
</template> 
 
<script> 
import Vue from 'vue'; 
import { SpreadsheetPlugin } from '@syncfusion/ej2-vue-spreadsheet'; 
 
Vue.use(SpreadsheetPlugin); 
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"); 
      request.send(); 
    } 
  } 
</script> 
 
 
Could you please check the above sample and get back to us if you need further assistance on this? 
 
Regards, 
Saranya D 


William Morgenweck
Replied On 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?

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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon