0

I am currently using Apache POI to transform a spreadsheet to HTML.

Though I am able to construct a decent HTML with commonly used API methods of POI. I am restrained in achieving a format for my requirement.

It is possible for a cell value to overflow to next cells without merging neighboring cells when current cell value is lengthier. This is the image for understanding.

enter image description here

Though I can get column width through this method - Sheet and can understand that text in column 'R' (from above image) is not wrapped, I don't have a method to know the number of cells this value is over-flowing.

Why I need this? I require my HTML to look as similar as spreadsheet.

While converting to HTML file, I wish to find 'colspan' attribute for <td> respective to the length of cell value.

Could you please enlighten me to correct API method or a workaround?

Thanks in advance!

Manoj
  • 149
  • 1
  • 3
  • 12
  • If you wanted to autoresize the column before converting to HTML (doesn't seem like that's the case though) you could use `autoSizeColumn(columnNumber)` to resize first... just a thought. – Tim S. Aug 01 '17 at 18:44

1 Answers1

0

This might seem a bit hacky, but one thing you could try is to get the column width using getColumnWidth, and then testing the "visible" width of the cells until you get to that width (how many cells does it take to get to that width) then the number of cells it takes to display would be your colspan value.

Hopefully that makes sense.

Tim S.
  • 2,187
  • 1
  • 25
  • 40
  • Seems to be a plan. Going to try this. In the mean time, the method - getColumnWidth gives you width of column or width of cell value? – Manoj Aug 02 '17 at 11:49
  • Could you please explain this - "visible" width of the cells? – Manoj Aug 02 '17 at 12:03
  • I thought there were different methods to get the actual cell width (what you see) and another to get the width of the data within the cell. If that's the case, you could calculate how many cells the overflow takes. I may be mistaken though. – Tim S. Aug 02 '17 at 13:51