| 
									
										
										
										
											2017-05-15 15:48:44 +00:00
										 |  |  | import XLSX = require('xlsx'); | 
					
						
							| 
									
										
										
										
											2015-06-03 13:34:42 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-15 15:48:44 +00:00
										 |  |  | const options: XLSX.ParsingOptions = { | 
					
						
							| 
									
										
										
										
											2017-05-12 21:46:39 +00:00
										 |  |  |     cellDates: true | 
					
						
							| 
									
										
										
										
											2015-06-03 13:34:42 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-16 17:45:35 +00:00
										 |  |  | const workbook: XLSX.WorkBook = XLSX.readFile('test.xlsx', options); | 
					
						
							|  |  |  | const otherworkbook: XLSX.WorkBook = XLSX.readFile('test.xlsx', {type: 'file'}); | 
					
						
							| 
									
										
										
										
											2015-06-03 13:34:42 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-16 17:45:35 +00:00
										 |  |  | const author: string = workbook.Props.Author; | 
					
						
							| 
									
										
										
										
											2015-06-03 13:34:42 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-12 21:46:46 +00:00
										 |  |  | const firstsheet: string = workbook.SheetNames[0]; | 
					
						
							| 
									
										
										
										
											2015-06-03 13:34:42 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-16 17:45:35 +00:00
										 |  |  | const firstworksheet: XLSX.WorkSheet = workbook.Sheets[firstsheet]; | 
					
						
							| 
									
										
										
										
											2015-06-03 13:34:42 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-16 17:45:35 +00:00
										 |  |  | const WB1A1: XLSX.CellObject = (firstworksheet["A1"]); | 
					
						
							| 
									
										
										
										
											2015-06-03 13:34:42 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-13 23:37:23 +00:00
										 |  |  | interface Tester { | 
					
						
							| 
									
										
										
										
											2017-05-12 21:46:39 +00:00
										 |  |  |     name: string; | 
					
						
							| 
									
										
										
										
											2015-06-03 13:34:42 +00:00
										 |  |  |     age: number; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-15 15:48:44 +00:00
										 |  |  | const jsonvalues: Tester[] = XLSX.utils.sheet_to_json<Tester>(firstworksheet); | 
					
						
							| 
									
										
										
										
											2017-05-16 17:45:35 +00:00
										 |  |  | const csv: string = XLSX.utils.sheet_to_csv(firstworksheet); | 
					
						
							|  |  |  | const formulae: string[] = XLSX.utils.sheet_to_formulae(firstworksheet); | 
					
						
							|  |  |  | const aoa: any[][] = XLSX.utils.sheet_to_json<any[]>(firstworksheet, {raw:true, header:1}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const aoa2: XLSX.WorkSheet = XLSX.utils.aoa_to_sheet<number>([ | 
					
						
							|  |  |  | 	[1,2,3,4,5,6,7], | 
					
						
							|  |  |  | 	[2,3,4,5,6,7,8] | 
					
						
							|  |  |  | ]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const js2ws: XLSX.WorkSheet = XLSX.utils.json_to_sheet<Tester>([ | 
					
						
							|  |  |  | 	{name:"Sheet", age: 12}, | 
					
						
							|  |  |  | 	{name:"JS", age: 24} | 
					
						
							|  |  |  | ]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const WBProps = workbook.Workbook; | 
					
						
							|  |  |  | const WBSheets = WBProps.Sheets; | 
					
						
							|  |  |  | const WBSheet0 = WBSheets[0]; | 
					
						
							|  |  |  | console.log(WBSheet0.Hidden); |