Apache POI sheet page break - apache

If I have cell coordinate, can I somehow get sheets next page break coordinate for first cell? I need this for printing purposes, because I'm making rather complex report and I want to copy in last page explanations. Row sizes varies, so I can't depend on fixed row count.

Related

Is There a More Efficient Way of Determining Whether a Table Row Spills Over Into the Footer Than Looping Through All Cells?

I'm currently using Microsoft Word 2016 VBA to programmatically set the AllowBreakAcrossPages setting so that if a row's contents overlaps the footer contents, I toggle the setting so that the row can break across pages. To solve this issue, I'm thinking about looping through all the cells of each table in the document and get the wdVerticalPositionRelativeToPage.Information of the last characters in each cell and comparing it to the footer's height relative to the page. If the last character's height is greater than the footer's, I set the row to break across pages. You can imagine that this is taking a while in a document that has many tables and cells. Is there a more efficient way to know if the row contents overlap the footer contents than looping through each cell in the row to see if a cell is causing the row to overlap the footer?
I tried using the row height property but discovered that if the HeightRule property of the specified row is wdRowHeightAuto then that means I can't access the row height via VBA.
I discovered that it's possible to use wdVerticalPositionRelativeToPage.Information with a row by row comparison of the prior and next rows like described in another posting - https://stackoverflow.com/a/14753231/4372244.
The only problem with that solution is that it doesn't work for the last row in a table or if it's the last row on a page.
Therefore, I'm examining a cell by cell solution.

How to set the cell value for displayed cells only?

I have some data I want to display in a StringGrid. This data contains many rows with some pretty static columns but also two columns that need web-API lookups and take some time to gather. SO when I try to set these cells in the OnShow of the StringGrid (or any other "Init") I get a long delay until the cell values are set.
What I would like to do is only look up the values for those cells that are currently displayed (and not all of them at once).
How Do I find out which rows are currently displayed? Is there an event I can use?

How can I determine whether a table row immediately follows a page break

Given a Word table which spans several pages, how can my code determine that a table row is the first following an automatic page break? Note that table rows are of different heights thus a solution of the form "every 13th row is the first row on a new page" won't work.
The point of this would be to add extra text in the first cell at the top of every new page.
Use wdActiveEndPageNumber for that table row. Be sure that row is as big as it's going to get before checking the page number.
n = word.ActiveDocument.Tables(a).rows(b).Range.Information(wdActiveEndPageNumber)
If the table is sufficiently large that it splits over several pages then you compare the page number of consecutive rows until the page number changes. There are no pagebreaks to speak of.

AutoFit not adjusting row height in VBA code in Excel 2007

I know many discussions have addressed this but I have not found a solution.
I regularly produce worksheets with about 100 records of text and date fields, each of which must be transposed into a 2-column table and printed to a PDF file.
To do this I have been using VBA code which works through the worksheet rows to sequentially: copy/transpose into two columns in a separate worksheet (Template) and then use rng.ExportAsFixedFormat Type:=xlTypePDF to create the PDF file.
It has all been working fine for several years, until someone recently noticed that sometimes the largest field does not show all the text from the Excel cell. It is invariably cut off after about 1000 - 1100 characters.
Many discussions mention that there is a 1024 limit on cell displays, but I thought this only applied to Excel 2003 and before - 2007 should be fine shouldn't it? In any case, I have found it is always possible to manually adjust the Excel field to reveal all of the text (both in the original worksheet and the temporary 2-column Excel table), sometimes totalling more than 2000 characters. Of course, I don't want to manually adjust and print to PDF 100 times on a regular basis. So I used AutoFit: Sheets("Template").Rows("1:18").Selection.EntireRow.AutoFit
Unfortunately this does not seem to duplicate the manual cell expanding that we have tried successfully. None of the cells is merged. All are wrapped and General formatted. I have tried cleaning text entries via Notepad before entry and inserting blank rows with Alt-F (as suggested elsewhere).
If AutoFit will not work, I am thinking maybe I could include some code to set a customised row height for each table by getting the total word count (is there a function?) and setting row height to about 0.8 * number of words - based on initial calculations.
Any ideas please?
I've used a method similar to what you suggested your last paragraph but with a character count instead of a word count. The VBA function is:
len(range("A1").value)
I did it since I had merged cells and they wouldn't autofit.
You'll have to calibrate for your column width, font and font size but from what I've learned there's no exact method. If you set your characters per line factor too high you might cut off a line, too low and you might get a blank line.

Where is this EXCEL Sheet's data stored?

I am stuck at this problem which involves extracting data from a excel spreadsheet. And the values are "hidden" behind a "interface". I was given a excel file with the coordinate system and for the specified coordinates, when you click on them, a value is displayed to you on the small window above the spreadsheet.
I need all these values and I am sure that I could extract them all at once, not one by one.
So I need to gather all the values that are assigned to the specific coordinates and implement it in my program. Also there is this red-green interface which points out if the value is above a specified number.
But how do I get to the values?
Excel Spreadsheet Link.
They are stored in that row by column. The reason that you cannot see them when you open it is that the size of the column have been reduced. To see the actual number in the row by column, just expand that column by dragging it to the right. For example, in spreadsheet EEM_80_Eini+Ausi, if you look at cell B3 and expand the row and column, you will see the number .2450610558 inside that cell.