@@ -65,12 +65,12 @@ export class ExcelProcessor extends BaseProcessor {
6565 * @param tree - Full AAC tree for navigation context
6666 * @param usedNames - Set of already used worksheet names to avoid duplicates
6767 */
68- private async convertPageToWorksheet (
68+ private convertPageToWorksheet (
6969 workbook : ExcelJS . Workbook ,
7070 page : AACPage ,
7171 tree : AACTree ,
7272 usedNames : Set < string > = new Set ( )
73- ) : Promise < void > {
73+ ) : void {
7474 // Create worksheet with page name (sanitized for Excel and unique)
7575 const worksheetName = this . getUniqueWorksheetName ( page . name || page . id , usedNames ) ;
7676 const worksheet = workbook . addWorksheet ( worksheetName ) ;
@@ -81,16 +81,16 @@ export class ExcelProcessor extends BaseProcessor {
8181 // Add navigation row if enabled (optional feature)
8282 let startRow = 1 ;
8383 if ( this . shouldAddNavigationRow ( ) ) {
84- await this . addNavigationRow ( worksheet , page , tree ) ;
84+ this . addNavigationRow ( worksheet , page , tree ) ;
8585 startRow = 2 ; // Start content after navigation row
8686 }
8787
8888 // Convert grid layout if available
8989 if ( page . grid && page . grid . length > 0 ) {
90- await this . convertGridLayout ( worksheet , page . grid , startRow ) ;
90+ this . convertGridLayout ( worksheet , page . grid , startRow ) ;
9191 } else {
9292 // Convert button list to grid layout
93- await this . convertButtonsToGrid ( worksheet , page . buttons , rows , cols , startRow ) ;
93+ this . convertButtonsToGrid ( worksheet , page . buttons , rows , cols , startRow ) ;
9494 }
9595
9696 // Apply worksheet formatting
@@ -133,18 +133,18 @@ export class ExcelProcessor extends BaseProcessor {
133133 * @param grid - 2D array of AAC buttons
134134 * @param startRow - Starting row number
135135 */
136- private async convertGridLayout (
136+ private convertGridLayout (
137137 worksheet : ExcelJS . Worksheet ,
138138 grid : Array < Array < AACButton | null > > ,
139139 startRow : number
140- ) : Promise < void > {
140+ ) : void {
141141 for ( let row = 0 ; row < grid . length ; row ++ ) {
142142 for ( let col = 0 ; col < grid [ row ] . length ; col ++ ) {
143143 const button = grid [ row ] [ col ] ;
144144 if ( button ) {
145145 const excelRow = startRow + row ;
146146 const excelCol = col + 1 ; // Excel columns are 1-based
147- await this . setButtonCell ( worksheet , button , excelRow , excelCol ) ;
147+ this . setButtonCell ( worksheet , button , excelRow , excelCol ) ;
148148 }
149149 }
150150 }
@@ -158,13 +158,13 @@ export class ExcelProcessor extends BaseProcessor {
158158 * @param cols - Number of columns in grid
159159 * @param startRow - Starting row number
160160 */
161- private async convertButtonsToGrid (
161+ private convertButtonsToGrid (
162162 worksheet : ExcelJS . Worksheet ,
163163 buttons : AACButton [ ] ,
164164 rows : number ,
165165 cols : number ,
166166 startRow : number
167- ) : Promise < void > {
167+ ) : void {
168168 for ( let i = 0 ; i < buttons . length ; i ++ ) {
169169 const button = buttons [ i ] ;
170170 const row = Math . floor ( i / cols ) ;
@@ -173,7 +173,7 @@ export class ExcelProcessor extends BaseProcessor {
173173 if ( row < rows ) {
174174 const excelRow = startRow + row ;
175175 const excelCol = col + 1 ; // Excel columns are 1-based
176- await this . setButtonCell ( worksheet , button , excelRow , excelCol ) ;
176+ this . setButtonCell ( worksheet , button , excelRow , excelCol ) ;
177177 }
178178 }
179179 }
@@ -185,12 +185,12 @@ export class ExcelProcessor extends BaseProcessor {
185185 * @param row - Excel row number
186186 * @param col - Excel column number
187187 */
188- private async setButtonCell (
188+ private setButtonCell (
189189 worksheet : ExcelJS . Worksheet ,
190190 button : AACButton ,
191191 row : number ,
192192 col : number
193- ) : Promise < void > {
193+ ) : void {
194194 const cell = worksheet . getCell ( row , col ) ;
195195
196196 // Set cell value to button label
@@ -220,10 +220,10 @@ export class ExcelProcessor extends BaseProcessor {
220220 * @param cell - Excel cell to style
221221 * @param style - AAC style object
222222 */
223- private applyCellStyling ( cell : ExcelJS . Cell , style : any ) : void {
224- const fill : any = { } ;
225- const font : any = { } ;
226- const border : any = { } ;
223+ private applyCellStyling ( cell : ExcelJS . Cell , style : AACStyle ) : void {
224+ const fill : Partial < ExcelJS . Fill > = { } ;
225+ const font : Partial < ExcelJS . Font > = { } ;
226+ const border : Partial < ExcelJS . Borders > = { } ;
227227
228228 // Background color
229229 if ( style . backgroundColor ) {
@@ -299,7 +299,7 @@ export class ExcelProcessor extends BaseProcessor {
299299 * @param color - Color string (hex, rgb, etc.)
300300 * @returns ARGB color string
301301 */
302- private convertColorToArgb ( color : string ) : string {
302+ private convertColorToArgb ( color ? : string ) : string {
303303 if ( ! color ) return 'FFFFFFFF' ; // Default white
304304
305305 // Remove any whitespace
@@ -380,11 +380,7 @@ export class ExcelProcessor extends BaseProcessor {
380380 * @param page - Current AAC page
381381 * @param tree - Full AAC tree for navigation context
382382 */
383- private async addNavigationRow (
384- worksheet : ExcelJS . Worksheet ,
385- page : AACPage ,
386- tree : AACTree
387- ) : Promise < void > {
383+ private addNavigationRow ( worksheet : ExcelJS . Worksheet , page : AACPage , tree : AACTree ) : void {
388384 const navButtons = ExcelProcessor . NAVIGATION_BUTTONS ;
389385
390386 for ( let i = 0 ; i < navButtons . length ; i ++ ) {
@@ -469,9 +465,9 @@ export class ExcelProcessor extends BaseProcessor {
469465 // - Max 31 characters
470466 // - Cannot contain: \ / ? * [ ] :
471467 // - Cannot be empty
472- const cleaned = ( name || '' )
473- . replace ( / [ \\ \/ \? \* \[ \] : ] / g, '_' )
474- . substring ( 0 , 31 ) ;
468+ let cleaned = ( name || '' ) . replace ( / [ \\ / ? * : ] / g , '_' ) ;
469+ cleaned = cleaned . replace ( / \[ / g , '_' ) . replace ( / \] / g, '_' ) ;
470+ cleaned = cleaned . substring ( 0 , 31 ) ;
475471
476472 if ( cleaned . length === 0 ) {
477473 return 'Sheet1' ;
@@ -488,7 +484,7 @@ export class ExcelProcessor extends BaseProcessor {
488484 */
489485 private getUniqueWorksheetName ( name : string , usedNames : Set < string > ) : string {
490486 const baseName = this . sanitizeWorksheetName ( name ) ;
491- const normalize = ( value : string ) => value . toLowerCase ( ) ;
487+ const normalize = ( value : string ) : string => value . toLowerCase ( ) ;
492488 let uniqueName = baseName ;
493489 let counter = 1 ;
494490
@@ -537,15 +533,13 @@ export class ExcelProcessor extends BaseProcessor {
537533
538534 try {
539535 await this . saveFromTreeAsync ( tree , outputPath ) ;
540- } catch ( error : any ) {
541- console . error ( 'Failed to save Excel file:' , error ) ;
536+ } catch ( error : unknown ) {
537+ const message = error instanceof Error ? error . message : String ( error ) ;
538+ console . error ( 'Failed to save Excel file:' , message ) ;
542539 try {
543540 const fallbackPath = outputPath . replace ( / \. x l s x $ / i, '_error.txt' ) ;
544541 fs . mkdirSync ( path . dirname ( fallbackPath ) , { recursive : true } ) ;
545- fs . writeFileSync (
546- fallbackPath ,
547- `Error saving Excel file: ${ error ?. message || String ( error ) } `
548- ) ;
542+ fs . writeFileSync ( fallbackPath , `Error saving Excel file: ${ message } ` ) ;
549543 } catch ( writeError ) {
550544 console . error ( 'Failed to write Excel error file:' , writeError ) ;
551545 }
@@ -578,7 +572,7 @@ export class ExcelProcessor extends BaseProcessor {
578572 // Convert each AAC page to an Excel worksheet
579573 for ( const pageId in tree . pages ) {
580574 const page = tree . pages [ pageId ] ;
581- await this . convertPageToWorksheet ( workbook , page , tree , usedNames ) ;
575+ this . convertPageToWorksheet ( workbook , page , tree , usedNames ) ;
582576 }
583577
584578 // Save the workbook
0 commit comments