format entire column #2802

Open
opened 2 months ago by slymuffhugger · 1 comments
slymuffhugger commented 2 months ago (Migrated from github.com)
Owner

This is more of a question. I have scoured the internet trying to find out if there is a way to format an entire column as text. My "source" sheet has the entire column formatted as text but only the header row is text when I download/save it. The source file is just a "template" with only the header row having values. Rest are blank rows.

this is all I am doing in my code example (result is an arrayBuffer coming from the .NET webapi)

this.carrierRatesService.getCarrierRatesFileTemplate()
      .subscribe(result => {
        if (result.byteLength > 0) {
          const wb = xlsx.read(result, { type: 'buffer', cellStyles: true });
          const fileName = 'CarrierRatesTemplate.xlsx';
          xlsx.writeFile(wb, fileName)
        }})

This is the source file (7th row showing as Text datatype)
image

This is the result of my download (7th row as General datatype)
image

Is there a way to set an entire column manually? It is causing leading 0's to be cut off.

This is more of a question. I have scoured the internet trying to find out if there is a way to format an entire column as text. My "source" sheet has the entire column formatted as text but only the header row is text when I download/save it. The source file is just a "template" with only the header row having values. Rest are blank rows. this is all I am doing in my code example (result is an arrayBuffer coming from the .NET webapi) ```typescript this.carrierRatesService.getCarrierRatesFileTemplate() .subscribe(result => { if (result.byteLength > 0) { const wb = xlsx.read(result, { type: 'buffer', cellStyles: true }); const fileName = 'CarrierRatesTemplate.xlsx'; xlsx.writeFile(wb, fileName) }}) ``` This is the source file (7th row showing as Text datatype) ![image](https://user-images.githubusercontent.com/27185349/193101761-80360abc-1db6-4551-a07c-744a41df64eb.png) This is the result of my download (7th row as General datatype) ![image](https://user-images.githubusercontent.com/27185349/193101886-cb37e28b-0113-45b6-b620-fa99eec5fb06.png) Is there a way to set an entire column manually? It is causing leading 0's to be cut off.
slymuffhugger commented 2 months ago (Migrated from github.com)
Owner

A "hacky" way that I made it work but decided not to use was to add a space in the columns I wanted to retain the type for like 1000 rows.. So I'm guessing it just doesn't pass through formatting information on null value cells

A "hacky" way that I made it work but decided not to use was to add a space in the columns I wanted to retain the type for like 1000 rows.. So I'm guessing it just doesn't pass through formatting information on null value cells
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#2802
Loading…
There is no content yet.