Inserting rows shift HorizPageBreaks

Questions and answers on how to use XLSReadWriteII 3/4/5.
Post Reply
lam1809
Posts: 3
Joined: Wed Sep 14, 2011 5:20 pm

Inserting rows shift HorizPageBreaks

Post by lam1809 »

I have Excel file with HorizPageBreaks.
I read it and insert rows in begin of it.
xrw.Sheet[0].Rows.InsertRows(nRow,nCount);

After saving I see that HorizPageBreaks was shift from his places up on nCount.

Its is Error or So must be?
lam1809
Posts: 3
Joined: Wed Sep 14, 2011 5:20 pm

Re: Inserting rows shift HorizPageBreaks

Post by lam1809 »

Inserting rows not change value of row in collection HorizPageBreaks!

I dicided this so:

procedure xrwInsertRow(xrw: TXLSReadWriteII4; nRow:integer;nRowsCount:integer=1);
var
i: integer;
begin
xrw.Sheet[xrwSheet].InsertRows(nRow,nRowsCount); //вставим пустую строку
for i:=0 to xrw.Sheet[xrwSheet].PrintSettings.HorizPagebreaks.Count-1 do
if xrw.Sheet[xrwSheet].PrintSettings.HorizPagebreaks[i].Row>nRow then
xrw.Sheet[xrwSheet].PrintSettings.HorizPagebreaks[i].Row:=xrw.Sheet[xrwSheet].PrintSettings.HorizPagebreaks[i].Row+nRowsCount;
end;
james321
Posts: 1
Joined: Thu Jul 26, 2012 11:20 am

Re: Inserting rows shift HorizPageBreaks

Post by james321 »

Select the cell or the range of cells where you want to insert the new blank cells. Select the same number of cells as you want to insert. For example, to insert five blank cells, you need to select five cells.

Show How to select cells or ranges

On the Insert menu, click Cells.

Tip You can also right-click the selected cells and then click Insert on the shortcut menu.

In the Insert dialog box, click the direction in which you want to shift the surrounding cells.

Notes

When you insert cells on your worksheet, all references that are affected by the insertion adjust accordingly, whether they are relative or absolute references. The same applies to deleting cells, except when a deleted cell is directly referenced by a formula. If you want references to adjust automatically, it's a good idea to use range references whenever appropriate in your formulas, rather than specifying individual cells.
You can insert cells that contain data and formulas by copying or cutting them and then clicking Copied Cells or Cut Cells on the Insert menu.
james321
Post Reply