forked from sheetjs/docs.sheetjs.com
		
	webapi
This commit is contained in:
		
							parent
							
								
									9ae03ac35a
								
							
						
					
					
						commit
						9cf036b3f8
					
				| @ -95,8 +95,8 @@ mv duktape-2.7.0/src/*.{c,h} . | ||||
| 1) Download the standalone script, shim and test file: | ||||
| 
 | ||||
| <ul> | ||||
| <li><a href={`https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js`}>xlsx.full.min.js</a></li> | ||||
| <li><a href={`https://cdn.sheetjs.com/xlsx-latest/package/dist/shim.min.js`}>shim.min.js</a></li> | ||||
| <li><a href={`https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js`}>xlsx.full.min.js</a></li> | ||||
| <li><a href="https://sheetjs.com/pres.numbers">pres.numbers</a></li> | ||||
| </ul> | ||||
| 
 | ||||
|  | ||||
| @ -139,6 +139,13 @@ drop_dom_element.addEventListener("drop", handleDropAsync, false); | ||||
| 
 | ||||
| ## File System Access API | ||||
| 
 | ||||
| :::caution Limited Browser Support | ||||
| 
 | ||||
| At the time of writing, browser support was fairly limited.  Chrome introduced | ||||
| the feature in version 86.  Safari did not support File System Access API. | ||||
| 
 | ||||
| ::: | ||||
| 
 | ||||
| _Reading Files_ | ||||
| 
 | ||||
| `window.showOpenFilePicker` shows a file picker and resolves to an array of | ||||
| @ -220,7 +227,6 @@ function SheetJSRoundTripFileSystemAPI() { return ( <button onClick={async () => | ||||
|     suggestedName: "SheetJSRT.xlsx", | ||||
|     types: [ { description: 'XLSX', accept: { 'application/vnd.ms-excel': ['.xlsx'] } } ] | ||||
|   }); | ||||
|   console.log(wFile); | ||||
|   const wstream = await wFile.createWritable(); | ||||
| 
 | ||||
|   /* write */ | ||||
| @ -237,8 +243,14 @@ function SheetJSRoundTripFileSystemAPI() { return ( <button onClick={async () => | ||||
| 
 | ||||
| ## File and Directory Entries API | ||||
| 
 | ||||
| In the web browser, the File and Directory Entries API does not project to the | ||||
| local file system. `cordova-plugin-file` *does* write to device in mobile apps! | ||||
| :::caution Deprecated | ||||
| 
 | ||||
| In the web browser, the File and Directory Entries API has been deprecated and | ||||
| is not recommended for new applications. | ||||
| 
 | ||||
| `cordova-plugin-file` still uses the API patterns. | ||||
| 
 | ||||
| ::: | ||||
| 
 | ||||
| _Writing Files_ | ||||
| 
 | ||||
|  | ||||
| @ -36,8 +36,8 @@ This demo includes all of the support files for the Flash and ActiveX methods. | ||||
| 1) Download the standalone script and shim to a server that will host the demo: | ||||
| 
 | ||||
| <ul> | ||||
| <li><a href={`https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js`}>xlsx.full.min.js</a></li> | ||||
| <li><a href={`https://cdn.sheetjs.com/xlsx-latest/package/dist/shim.min.js`}>shim.min.js</a></li> | ||||
| <li><a href={`https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js`}>xlsx.full.min.js</a></li> | ||||
| </ul> | ||||
| 
 | ||||
| 2) [Download the demo ZIP](pathname:///ie/SheetJSIESupport.zip) to the server. | ||||
|  | ||||
| @ -186,6 +186,7 @@ The first argument to the post-processing script is the filename.  The file can | ||||
| be read with `XLSX.readFile` directly. `XLSX.utils.sheet_to_csv` generates CSV: | ||||
| 
 | ||||
| ```ts title="postprocess.ts" | ||||
| // @deno-types="https://cdn.sheetjs.com/xlsx-latest/package/types/index.d.ts" | ||||
| import * as XLSX from 'https://cdn.sheetjs.com/xlsx-latest/package/xlsx.mjs'; | ||||
| /* load the codepage support library for extended support with older formats  */ | ||||
| import * as cptable from 'https://cdn.sheetjs.com/xlsx-latest/package/dist/cpexcel.full.mjs'; | ||||
| @ -242,7 +243,6 @@ You will be redirected to the new project. | ||||
|    the main editor window: | ||||
| 
 | ||||
| ```ts title="postprocess.ts" | ||||
| import { writeCSV } from "https://deno.land/x/flat/mod.ts"; | ||||
| // @deno-types="https://cdn.sheetjs.com/xlsx-latest/package/types/index.d.ts" | ||||
| import * as XLSX from 'https://cdn.sheetjs.com/xlsx-latest/package/xlsx.mjs'; | ||||
| /* load the codepage support library for extended support with older formats  */ | ||||
| @ -261,7 +261,8 @@ const first_sheet = workbook.Sheets[workbook.SheetNames[0]]; | ||||
| const csv = XLSX.utils.sheet_to_csv(first_sheet); | ||||
| 
 | ||||
| /* write CSV */ | ||||
| await writeCSV(out_file, csv); | ||||
| // highlight-next-line | ||||
| Deno.writeFileSync(out_file, new TextEncoder().encode(csv)); | ||||
| ``` | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -4,9 +4,12 @@ sidebar_position: 4 | ||||
| 
 | ||||
| # Workbook Object | ||||
| 
 | ||||
| `workbook.SheetNames` is an ordered list of the sheets in the workbook | ||||
| For a given workbook object `wb`: | ||||
| 
 | ||||
| `wb.Sheets[sheetname]` returns an object representing the worksheet. | ||||
| `wb.SheetNames` is an ordered list of the sheets in the workbook. | ||||
| 
 | ||||
| `wb.Sheets` is an object whose keys are worksheet names (from `SheetNames`) and | ||||
| whose values are worksheet objects. | ||||
| 
 | ||||
| `wb.Props` is an object storing the standard properties.  `wb.Custprops` stores | ||||
| custom properties.  Since the XLS standard properties deviate from the XLSX | ||||
| @ -14,6 +17,8 @@ standard, XLS parsing stores core properties in both places. | ||||
| 
 | ||||
| `wb.Workbook` stores [workbook-level attributes](#workbook-level-attributes). | ||||
| 
 | ||||
| When reading a file, `wb.bookType` is the determined book type. | ||||
| 
 | ||||
| ## File Properties | ||||
| 
 | ||||
| The various file formats use different internal names for file properties.  The | ||||
|  | ||||
| @ -156,7 +156,6 @@ _Adding a cell to a range_ | ||||
| function range_add_cell(range, cell) { | ||||
|   var rng = XLSX.utils.decode_range(range); | ||||
|   var c = typeof cell == 'string' ? XLSX.utils.decode_cell(cell) : cell; | ||||
|   console.log(rng, c); | ||||
|   if(rng.s.r > c.r) rng.s.r = c.r; | ||||
|   if(rng.s.c > c.c) rng.s.c = c.c; | ||||
| 
 | ||||
|  | ||||
| @ -10,22 +10,19 @@ important to ensure code is cleanroom.  [Contribution Notes](https://raw.githubu | ||||
| <details> | ||||
|   <summary><b>File organization</b> (click to show)</summary> | ||||
| 
 | ||||
| At a high level, the final script is a concatenation of the individual files in | ||||
| the `bits` folder.  Running `make` should reproduce the final output on all | ||||
| platforms. | ||||
| 
 | ||||
| Folders: | ||||
| 
 | ||||
| | folder       | contents                                                      | | ||||
| |:-------------|:--------------------------------------------------------------| | ||||
| | `bits`       | raw source files that make up the final script                | | ||||
| | `bin`        | server-side bin scripts (`xlsx.njs`)                          | | ||||
| | `bits`       | raw source files that make up the final script                | | ||||
| | `dist`       | dist files for web browsers and nonstandard JS environments   | | ||||
| | `demos`      | demo projects for platforms like ExtendScript and Webpack     | | ||||
| | `tests`      | browser tests (run `make ctest` to rebuild)                   | | ||||
| | `types`      | typescript definitions and tests                              | | ||||
| | `misc`       | miscellaneous supporting scripts                              | | ||||
| | `modules`    | TypeScript source files that generate some of the bits        | | ||||
| | `packages`   | Support libraries and tools                                   | | ||||
| | `test_files` | test files (pulled from the test files repository)            | | ||||
| | `tests`      | browser tests (run `make ctest` to rebuild)                   | | ||||
| | `types`      | TypeScript definitions and tests                              | | ||||
| 
 | ||||
| </details> | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user