created() cannot trriger and nothing happens when cellFormat() is called

Below is my code, please help to see where is the problem


<nzo-sheet [data]="stRows" [columns]="sheetColumns" style="height: calc(100vh - 88px);"></nzo-sheet>

-------- nzo-sheet.component.ts ------------

@Component({
  selector: 'nzo-sheet',
  templateUrl: './nzo-sheet.component.html',
  styleUrls: ['./nzo-sheet.component.less']
})
export class NzoSheetComponent implements OnInit, AfterViewInit {
  @ViewChild('spreadsheet', { static: false})
  public spreadsheetObj: SpreadsheetComponent;

  public query: Query = null;
  public rowsTotal: number;
  public colsTotal: number;
  public colsLetter: string;
 
  @Input() title: string = 'Sheet1';
  @Input() data: Object[] = [{}];
  @Input() columns: NzoSheetColumn[] = [];

  public openUrl = 'https://ej2services.syncfusion.com/production/web-services/api/spreadsheet/open';
  public saveUrl = 'https://ej2services.syncfusion.com/production/web-services/api/spreadsheet/save';

  constructor(
    private deep: DeepService,
    private fmt: FormatService,
  ) { }

  ngOnInit() {
    if (this.columns.length>0) {
      this.query = new Query().select(this.deep.get(this.columns, 'index')).take(200);
    }
   
    // total rows count
    this.rowsTotal = this.data.length + 1; // +1 for header
    // total columns count
    this.colsTotal = this.columns.length || Object.keys(this.data[0]).length;
    // last column letter
    this.colsLetter = this.fmt.convertNumberToLetter(this.colsTotal);
  }

  ngAfterViewInit(): void {
    this.spreadsheetObj.cellFormat({ fontWeight: 'bold', textAlign: 'center' }, `A1:${this.colsLetter}1`);
  }

  created() {
    console.log('***', `A1:${this.colsLetter}${this.rowsTotal}`);
  }
}

-------- NzoSheetComponent  End ------------
-------- nzo-sheet.component.html -----------

<ejs-spreadsheet #spreadsheet [openUrl]="openUrl" [saveUrl]="saveUrl" (created)="created()" style="height: 100%;">
  <e-sheets>
    <e-sheet [name]="title">
      <e-ranges>
        <e-range [dataSource]="data" [query]="query"></e-range>
      </e-ranges>
      <e-columns>
        <e-column *ngFor="let c of columns" [width]=c.width></e-column>
      </e-columns>
    </e-sheet>
  </e-sheets>
</ejs-spreadsheet>

-------- nzo-sheet.component.html end -----------

1 Reply

SP Sangeetha Priya Murugan Syncfusion Team June 21, 2022 11:06 AM UTC

Hi Kenny,


We have checked your issue based on your provided codes and the created event triggered properly in our end. Please find the sample link below.


Sample Link: https://stackblitz.com/edit/angular-dwfdbn?file=app.component.ts,app.component.html


Before we proceed further, please share the below details.


1.Please replicate your issue in the above sample and send back to us.

2.Share the stack trace if you have received any console error.

3.Essential studio product version that you are using.

4.If possible, please share the issue replicable sample.


Could you please check the above details and get back to us with the above requested information, based on that we will check and provide you a better solution quickly.


Regards,

Sangeetha M



Loader.
Up arrow icon