jspreadsheet / pro

Jspreadsheet Pro | The javascript spreadsheet
https://jspreadsheet.com/
14 stars 1 forks source link

Can we set string-typed cells to align left #309

Closed dmt0 closed 7 months ago

dmt0 commented 7 months ago

I can't find a setting to change cell alignment. Can't set those with CSS either, cause I'd have to use !important which would make it impossible for users to set alignment from the toolbar. I would specifically want to change alignment for strings and numbers.

hodeware commented 7 months ago

Here is two different ways, native or via CSS without !important https://jsfiddle.net/d82tg9qe/10/

jspreadsheet(document.getElementById('spreadsheet'), {
    tabs: true,
    toolbar: true,
    worksheets: [{
        minDimensions: [3,3],
        style: { A1: 'text-align: left' },
        data: [['native', 'external']]
    }],
});```

```css
.jss > tbody > tr > td[data-x='1'] {
  text-align: left;
}
dmt0 commented 7 months ago

Hi Paul, I'm not looking to set one cell. I want all cells by default to be aligned right if they are numbers, and left if they are stings. Exactly like Google Sheet.

hodeware commented 7 months ago

All number columns are default align to the right, to change default aligment for text please use: defaultColAlign

Here is working example: https://jsfiddle.net/d82tg9qe/12/