Skip to content

Commit 6d1c17c

Browse files
1003858: Updated Open-save reorganization content for react
1 parent ee34e0e commit 6d1c17c

20 files changed

Lines changed: 1013 additions & 8 deletions

Document-Processing-toc.html

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5079,21 +5079,42 @@
50795079
<li><a href="/document-processing/excel/spreadsheet/react/getting-started">Getting Started</a></li>
50805080
<li><a href="/document-processing/excel/spreadsheet/react/nextjs-getting-started">Getting Started with NextJS</a></li>
50815081
<li><a href="/document-processing/excel/spreadsheet/react/data-binding">Data Binding</a></li>
5082-
<li><a href="/document-processing/excel/spreadsheet/react/open-save">Open and Save</a></li>
5082+
<li><a href="/document-processing/excel/spreadsheet/react/open/open">Open</a>
5083+
<li>
5084+
<ul>Open Excel File
5085+
<li><a href="/document-processing/excel/spreadsheet/react/open/open-excel-file/file-uploader">using a file uploader</a></li>
5086+
<li><a href="/document-processing/excel/spreadsheet/react/open/open-excel-file/external-url">using an external URL</a></li>
5087+
<li><a href="/document-processing/excel/spreadsheet/react/open/open-excel-file/blob-data">from blob data</a></li>
5088+
<li><a href="/document-processing/excel/spreadsheet/react/open/open-excel-file/base64-string">from base64 string</a></li>
5089+
<li><a href="/document-processing/excel/spreadsheet/react/open/open-excel-file/server">located on a server</a></li>
5090+
<li><a href="/document-processing/excel/spreadsheet/react/open/open-excel-file/aws-lambda">using AWS Lambda hosted web service</a></li>
5091+
</ul>
5092+
</li>
5093+
</li>
5094+
<li><a href="/document-processing/excel/spreadsheet/react/save/save">Save</a>
5095+
<li>Save Excel File
5096+
<ul>
5097+
<li><a href="/document-processing/excel/spreadsheet/react/save/save-excel-file/blob-data">as blob data</a></li>
5098+
<li><a href="/document-processing/excel/spreadsheet/react/save/save-excel-file/base64-string">as base64 string</a></li>
5099+
<li><a href="/document-processing/excel/spreadsheet/react/save/save-excel-file/server">to a server</a></li>
5100+
<li><a href="/document-processing/excel/spreadsheet/react/save/save-excel-file/aws-lambda">using AWS Lambda hosted web service</a></li>
5101+
</ul>
5102+
</li>
5103+
</li>
50835104
<li>Cloud Storage
50845105
<ul>
50855106
<li>Open From Cloud
50865107
<ul>
5087-
<li><a href="/Document-Processing/Excel/Spreadsheet/React/Cloud Storage/Open from Cloud/aws-s3-bucket">AWS S3</a></li>
5088-
<li><a href="/Document-Processing/Excel/Spreadsheet/React/Cloud Storage/Open from Cloud/azure-blob-storage">Azure Blob Storage</a></li>
5089-
<li><a href="/Document-Processing/Excel/Spreadsheet/React/Cloud Storage/Open from Cloud/google-cloud-storage">Google Cloud Storage</a></li>
5090-
</li>ul>
5108+
<li><a href="/document-processing/excel/spreadsheet/react/cloud-storage/open-from-cloud/aws-s3-bucket">AWS S3</a></li>
5109+
<li><a href="/document-processing/excel/spreadsheet/react/cloud-storage/open-from-cloud/azure-blob-storage">Azure Blob Storage</a></li>
5110+
<li><a href="/document-processing/excel/spreadsheet/react/cloud-storage/open-from-cloud/google-cloud-storage">Google Cloud Storage</a></li>
5111+
</ul>
50915112
</li>
50925113
<li>Save To Cloud
50935114
<ul>
5094-
<li><a href="/Document-Processing/Excel/Spreadsheet/React/Cloud Storage/Save to Cloud/aws-s3-bucket">AWS S3</a></li>
5095-
<li><a href="/Document-Processing/Excel/Spreadsheet/React/Cloud Storage/Save to Cloud/azure-blob-storage">Azure Blob Storage</a></li>
5096-
<li><a href="/Document-Processing/Excel/Spreadsheet/React/Cloud Storage/Save to Cloud/google-cloud-storage">Google Cloud Storage</a></li>
5115+
<li><a href="/document-processing/excel/spreadsheet/react/cloud-storage/save-to-cloud/aws-s3-bucket">AWS S3</a></li>
5116+
<li><a href="/document-processing/excel/spreadsheet/react/cloud-storage/save-to-cloud/azure-blob-storage">Azure Blob Storage</a></li>
5117+
<li><a href="/document-processing/excel/spreadsheet/react/cloud-storage/save-to-cloud/google-cloud-storage">Google Cloud Storage</a></li>
50975118
</ul>
50985119
</li>
50995120
</ul>

Document-Processing/Excel/Spreadsheet/React/Cloud Storage/Open from Cloud/aws-s3-bucket.md renamed to Document-Processing/Excel/Spreadsheet/React/Cloud-Storage/Open-from-Cloud/aws-s3-bucket.md

File renamed without changes.

Document-Processing/Excel/Spreadsheet/React/Cloud Storage/Open from Cloud/azure-blob-storage.md renamed to Document-Processing/Excel/Spreadsheet/React/Cloud-Storage/Open-from-Cloud/azure-blob-storage.md

File renamed without changes.

Document-Processing/Excel/Spreadsheet/React/Cloud Storage/Open from Cloud/google-cloud-storage.md renamed to Document-Processing/Excel/Spreadsheet/React/Cloud-Storage/Open-from-Cloud/google-cloud-storage.md

File renamed without changes.

Document-Processing/Excel/Spreadsheet/React/Cloud Storage/Save to Cloud/aws-s3-bucket.md renamed to Document-Processing/Excel/Spreadsheet/React/Cloud-Storage/Save-to-Cloud/aws-s3-bucket.md

File renamed without changes.

Document-Processing/Excel/Spreadsheet/React/Cloud Storage/Save to Cloud/azure-blob-storage.md renamed to Document-Processing/Excel/Spreadsheet/React/Cloud-Storage/Save-to-Cloud/azure-blob-storage.md

File renamed without changes.

Document-Processing/Excel/Spreadsheet/React/Cloud Storage/Save to Cloud/google-cloud-storage.md renamed to Document-Processing/Excel/Spreadsheet/React/Cloud-Storage/Save-to-Cloud/google-cloud-storage.md

File renamed without changes.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
layout: post
3+
title: Open using Lambda in React Spreadsheet component | Syncfusion
4+
description: Learn here all about opening Excel files using AWS Lambda in Syncfusion React Spreadsheet component of Syncfusion Essential JS 2 and more.
5+
platform: document-processing
6+
control: Open Excel using AWS Lambda
7+
documentation: ug
8+
---
9+
10+
# Open an excel file using a hosted web service in AWS Lambda
11+
12+
Before proceeding with the opening process, you should deploy the spreadsheet open/save web API service in AWS Lambda. To host the open/save web service in the AWS Lambda environment, please refer to the following KB documentation.
13+
14+
[How to deploy a spreadsheet open and save web API service to AWS Lambda](https://support.syncfusion.com/kb/article/17184/how-to-deploy-a-spreadsheet-open-and-save-web-api-service-to-aws-lambda)
15+
16+
After deployment, you will get the AWS service URL for the open and save actions. Before opening the Excel file with this hosted open URL, you need to prevent the default file opening process to avoid getting a corrupted file on the open service end. The spreadsheet component appends the file to the `formData` and sends it to the open service, which causes the file to get corrupted. To prevent this, set the `args.cancel` value to `true` in the [`beforeOpen`](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#beforeopen) event. After that, you will get the selected file in the `beforeOpen` event argument. Then, convert this file into a base64 string and send it to the open service URL using a fetch request.
17+
18+
On the open service end, convert the base64 string back to a file and pass it as an argument to the workbook `Open` method. The open service will process the file and return the spreadsheet data in JSON format. You will then receive this JSON data in the fetch success callback. Finally, use the [openFromJson](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#openfromjson) method to load this JSON data into the spreadsheet component.
19+
20+
The following code example shows how to open an Excel file using a hosted web service in AWS Lambda, as mentioned above.
21+
22+
```js
23+
function Default() {
24+
let spreadsheet;
25+
const beforeOpenHandler = (eventArgs) => {
26+
eventArgs.cancel = true; // To prevent the default open action.
27+
if (eventArgs.file) {
28+
const reader = new FileReader();
29+
reader.readAsDataURL(eventArgs.file);
30+
reader.onload = () => {
31+
// Removing the xlsx file content-type.
32+
const base64Data = reader.result.replace('data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,', '');
33+
openExcel({
34+
file: base64Data,
35+
extension: eventArgs.file.name.slice(eventArgs.file.name.lastIndexOf('.') + 1),
36+
password: eventArgs.password || ''
37+
});
38+
};
39+
}
40+
};
41+
const openExcel = (requestData) => {
42+
// Fetch call to AWS server for open processing.
43+
fetch('https://xxxxxxxxxxxxxxxxxx.amazonaws.com/Prod/api/spreadsheet/open', {
44+
method: 'POST',
45+
headers: {
46+
'Accept': 'application/json, text/plain',
47+
'Content-Type': 'application/json;charset=UTF-8'
48+
},
49+
body: JSON.stringify(requestData)
50+
}).then((response) => {
51+
if (response.ok) {
52+
return response.json();
53+
}
54+
}).then((data) => {
55+
// Loading the JSON data into our spreadsheet.
56+
if (data.Workbook && data.Workbook.sheets) {
57+
spreadsheet.openFromJson({ file: data });
58+
}
59+
}).catch((error) => {
60+
console.log(error);
61+
});
62+
};
63+
return (<div className='control-pane'>
64+
<div className='control-section spreadsheet-control'>
65+
<SpreadsheetComponent openUrl='https://xxxxxxxxxxxxxxxxxx.amazonaws.com/Prod/api/spreadsheet/open' ref={(ssObj) => { spreadsheet = ssObj; }} beforeOpen={beforeOpenHandler}>
66+
</SpreadsheetComponent>
67+
</div>
68+
</div>);
69+
}
70+
export default Default;
71+
```
72+
73+
```csharp
74+
public IActionResult Open(OpenOptions openOptions)
75+
{
76+
// Convert the base64 string to bytes array.
77+
byte[] bytes = Convert.FromBase64String(openOptions.File);
78+
// Loading the bytes array to stream.
79+
MemoryStream stream = new MemoryStream(bytes);
80+
OpenRequest open = new OpenRequest();
81+
// Converting the stream into FormFile.
82+
open.File = new FormFile(stream, 0, bytes.Length, "Sample", "Sample." + openOptions.Extension);
83+
if (string.IsNullOrEmpty(openOptions.Password))
84+
open.Password = openOptions.Password;
85+
var result = Workbook.Open(open);
86+
return Content(result);
87+
}
88+
89+
public class OpenOptions
90+
{
91+
public string File { get; set; } = string.Empty;
92+
public string Password { get; set; } = string.Empty;
93+
public string Extension { get; set; } = string.Empty;
94+
}
95+
```
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
layout: post
3+
title: Open from Base64 in React Spreadsheet component | Syncfusion
4+
description: Learn here all about how to Open an excel file from Base64 string data in Syncfusion React Spreadsheet component of Syncfusion Essential JS 2 and more.
5+
platform: document-processing
6+
control: base64
7+
documentation: ug
8+
---
9+
10+
# Open an excel file from Base64 string data
11+
12+
In the Syncfusion<sup style="font-size:70%">&reg;</sup> Spreadsheet component, there is no direct option to open data as a `Base64` string. To achieve this, the `import()` function fetches the `Base64` string, converts it to a Blob, creates a File object from the Blob, and then opens it using the [open](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#open) method in the spreadsheet.
13+
14+
The following code example shows how to open the spreadsheet data as base64 string.
15+
16+
{% tabs %}
17+
{% highlight js tabtitle="app.jsx" %}
18+
{% include code-snippet/spreadsheet/react/base-64-string/app/app.jsx %}
19+
{% endhighlight %}
20+
{% highlight ts tabtitle="app.tsx" %}
21+
{% include code-snippet/spreadsheet/react/base-64-string/app/app.tsx %}
22+
{% endhighlight %}
23+
{% endtabs %}
24+
25+
{% previewsample "/document-processing/code-snippet/spreadsheet/react/base-64-string" %}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
layout: post
3+
title: Open from Blob in React Spreadsheet component | Syncfusion
4+
description: Learn here all about how to Open an excel file from blob data in Syncfusion React Spreadsheet component of Syncfusion Essential JS 2 and more.
5+
platform: document-processing
6+
control: blob data
7+
documentation: ug
8+
---
9+
10+
# Open an excel file from blob data
11+
12+
By default, the Spreadsheet component provides an option to browse files from the local file system and open them within the component. If you want to open an Excel file from blob data, you need to fetch the blob data from the server or another source and convert this blob data into a `File` object. Then, you can use the [open](https://ej2.syncfusion.com/react/documentation/api/spreadsheet/index-default#open) method in the Spreadsheet component to load that `File` object.
13+
14+
Please find the code to fetch the blob data and load it into the Spreadsheet component below.
15+
16+
{% tabs %}
17+
{% highlight js tabtitle="app.jsx" %}
18+
{% include code-snippet/spreadsheet/react/open-from-blobdata-cs1/app/app.jsx %}
19+
{% endhighlight %}
20+
{% highlight ts tabtitle="app.tsx" %}
21+
{% include code-snippet/spreadsheet/react/open-from-blobdata-cs1/app/app.tsx %}
22+
{% endhighlight %}
23+
{% endtabs %}
24+
25+
{% previewsample "/document-processing/code-snippet/spreadsheet/react/open-from-blobdata-cs1" %}

0 commit comments

Comments
 (0)