question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Can't create columns in typescript

See original GitHub issue

🐛 Bug Report

I have created worksheet and using that worksheet i cant seems to create columns header.

const workbook = new Workbook();
workbook.creator = workbookName;

const worksheet = workbook.addWorksheet(workSheetName);
worksheet.columns = [
    { header: 'Id', key: 'id', width: 10 },
    { header: 'Name', key: 'name', width: 32 },
    { header: 'D.O.B.', key: 'DOB', width: 10, outlineLevel: 1 },
];

Error give. Type '{ header: string; key: string; width: number; }' is missing the following properties from type 'Column': outlineLevel, hidden, style, values, and 11 more.

It just seems like under Type Columns all is required.

Lib version: 4.2.0

Steps To Reproduce

const workbook = new Workbook();
workbook.creator = workbookName;

const worksheet = workbook.addWorksheet(workSheetName);
worksheet.columns = [
    { header: 'Id', key: 'id', width: 10 },
    { header: 'Name', key: 'name', width: 32 },
    { header: 'D.O.B.', key: 'DOB', width: 10, outlineLevel: 1 },
];

The expected behaviour:

Type '{ header: string; key: string; width: number; }' is missing the following properties from type 'Column': outlineLevel, hidden, style, values, and 11 more.

Possible solution (optional, but very helpful):

Make fields in Type Columns optional

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:22
  • Comments:10

github_iconTop GitHub Comments

15reactions
Aidam1commented, Jan 12, 2021

Where is the ExcelProper coming from @KingDarBoja ? I don’t see it in this lib.

@Artaud ExcelProper is just your default import of the library. You can name it differently.

import ExcelJS from 'exceljs';

worksheet.columns = [
    {header: 'id', key: 'id', width: 10},
] as ExcelJS.Column[];
11reactions
KingDarBojacommented, Dec 10, 2020

You can cast if you are using 4.2 in the meantime:

const workbook = new Workbook();
workbook.creator = workbookName;

const worksheet = workbook.addWorksheet(workSheetName);
worksheet.columns = [
    { header: 'Id', key: 'id', width: 10 },
    { header: 'Name', key: 'name', width: 32 },
    { header: 'D.O.B.', key: 'DOB', width: 10, outlineLevel: 1 },
] as as ExcelProper.Column[]; // :)
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeORM throws Error 'ER_CANT_CREATE_TABLE: Can\' ...
But somehow i keep getting that error. My entities are like below (Common entity is just an entity for basic Columns like id,...
Read more >
JavaScript Data Grid: Column Sizing
All columns can be resized by dragging the top right portion of the column. Enable Sizing. Turn column resizing on for the grid...
Read more >
The starting point for learning TypeScript
Find TypeScript starter projects: from Angular to React or Node.js and CLIs.
Read more >
console.table() - Web APIs | MDN
It logs data as a table. Each element in the array (or enumerable property if data is an object) will be a row...
Read more >
Typescript Error: Property 'registerRenderer' does not exist ...
In the demo link it does not throw this error, but in my refactored example I have also added 'checkbox' type in that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found