1
votes

I'm using Office.js to create an Add-in for Excel.

I'm able to get the exact styling (fill colors, font size, borders, etc) of individual cells of ranges and now need to do the same for cells of tables.

I'm able to get the the table's style and then get the style's properties. However, besides the fact that this is only supported since ExcelAPI 1.7, it seems to only describe the style in general terms. That is, it doesn't seem to describe the detailed table style properties such as "First row stripe", "Total row", etc.

(Note that getting the table's individual cell styles doesn't work like for cells of ranges. The styling properties, such as fill.color, don't represent the effectively applied styling of the cell if the cell's styling from the table's base style hasn't been overridden.)

Things I have considered:

  • Convert the table to a range. But I guess that this is destructive to the worksheet and I see no way of performing an undo.
  • Convert the table to a range and back to a table again. This is destructive as well and I'm afraid I could somehow not exactly recreate the table as it was before.
  • Create a copy of the worksheet and then covert the tables to ranges. That could work but it's ExcelAPI 1.7 only.
  • Read the raw style info from the file's OOXML representation but I don't think that that's possible with Office.js alone.

Any suggestion on how to get an Excel table's exact styling information using only Office.js and with an API version as low as possible?


Edit: Turns out we do have access to the whole .xlsx file with Office.js using the Office.context.document.getFileAsync method. I'll try to get the full style info by reading the xl/styles.xml file but I'd still prefer a better solution.

1

1 Answers

0
votes

You can still get range from the table you want to handle. For example, Var range = worksheet.getRange("A1:E1").

Although "A1:E1" is part of a table, you can still get the area as a range and do your further actions.