33Deno is a runtime capable of running JS code including this library.  There are
44a few different builds and recommended use cases as covered in this demo.
55
6- For user code, [ the ` sheetjs `  module] ( https://deno.land/x/sheetjs )  can be used.
6+ Due to ongoing stability and sync issues with the Deno registry, scripts should
7+ use [ the ` unpkg `  CDN build] ( https://unpkg.com/xlsx/xlsx.mjs ) :
8+ 
9+ ``` js 
10+ //  @deno-types="https://unpkg.com/xlsx/types/index.d.ts"
11+ import  *  as  XLSX  from  ' https://unpkg.com/xlsx/xlsx.mjs'  ;
12+ 
13+ /*  load the codepage support library for extended support with older formats  */ 
14+ import  *  as  cptable  from  ' https://unpkg.com/xlsx/dist/cpexcel.full.mjs'  ;
15+ XLSX .set_cptable (cptable);
16+ ``` 
17+ 
718
819## Reading and Writing Files  
920
1021In general, the command-line flag ` --allow-read `  must be passed to enable file
1122reading.  The flag ` --allow-write `  must be passed to enable file writing.
1223
13- Starting in version 0.18.1, this library will check for the ` Deno `  global and
14- use ` Deno.readFileSync `  and ` Deno.writeFileSync `  behind the scenes.
15- 
16- For older versions, the API functions must be called from user code.
17- 
1824_ Reading a File_ 
1925
2026``` ts 
21- const   filedata =  Deno .readFileSync (" test.xlsx"  );
22- const   workbook =  XLSX .read (filedata , {type: " buffer"  });
23- /*  DO SOMETHING WITH workbook HERE */ 
27+ const   workbook =  XLSX .readFile (" test.xlsx"  );
2428``` 
2529
2630_ Writing a File_ 
@@ -30,9 +34,7 @@ Older versions of the library did not properly detect features from Deno, so the
3034not handle byte arrays, user code must generate a ` Uint8Array `  first:
3135
3236``` ts 
33- const   buf =  XLSX .write (workbook , {type: " buffer"  , bookType: " xlsb"  });
34- const   u8:  Uint8Array  =  new  Uint8Array (buf );
35- Deno .writeFileSync (" test.xlsb"  , u8 );
37+ XLSX .writeFile (workbook , " test.xlsb"  );
3638``` 
3739
3840## Demos  
@@ -60,8 +62,8 @@ accepts the `XLSX` module as an argument.
6062-  ` x `  imports the ESM build without the codepage library:
6163
6264``` ts 
63- //  @deno-types="https://deno.land/x/sheetjs /types/index.d.ts"
64- import  *  as  XLSX  from  ' https://deno.land/x/sheetjs /xlsx.mjs'  ;
65+ //  @deno-types="https://unpkg.com/xlsx /types/index.d.ts"
66+ import  *  as  XLSX  from  ' https://unpkg.com/xlsx /xlsx.mjs'  ;
6567``` 
6668
6769-  ` mjs `  imports the ESM build and the associated codepage library:
@@ -73,12 +75,6 @@ import * as cptable from '../../dist/cptable.full.mjs';
7375XLSX .set_cptable (cptable );
7476``` 
7577
76- -  ` jspm `  imports the browser standalone script using JSPM:
77- 
78- ``` ts 
79- import  *  as  XLSX  from  ' https://jspm.dev/npm:xlsx!cjs'  ;
80- ``` 
81- 
8278-  ` node `  uses the node compatibility layer:
8379
8480``` ts 
0 commit comments