advisr-io / excel4node

Node module to allow for easy Excel file creation
MIT License
124 stars 19 forks source link

setWith is impossibly difficult -- lacks proper documentation #47

Open aprilmintacpineda opened 1 year ago

aprilmintacpineda commented 1 year ago

Google Sheets use pixels for column widths. I'm using LibreOffice which has centimeter.

I constructed this function:

function calcColumnWidthFromPx(desiredWidthPx: number) {
  const inchToPx = 96;
  const inchToCm = 2.54;
  return (desiredWidthPx / inchToPx) * inchToCm;
}

Which converts a width from pixels to centimeter, based on 96 pixels = 1 inch = 2.54 cm. However I still don't get the correct output that I want, I want to set the width of column 1 to 149px but it seems impossible because the unit of measurement being used by setWidth is not documented.