ReoGrid Forum

Fast and powerful .NET Spreadsheet Component

You are not logged in.

Announcement

This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.

https://github.com/unvell/ReoGrid/issues

#1 2015-12-27 16:26:33

h3nrik
Member
Registered: 2015-12-27
Posts: 2

RGF and v-border and h-borders, can't make any sense out of it...

Hi

Im trying to take the content of the .rgf and redraw all borders in another program, but I cant make sense out of it..

First, border all around A:1 give me

  <v-borders>
    <v-border row="0" col="0" color="Black" style="Solid" pos="left" rows="1" />
    <v-border row="0" col="1" color="Black" style="Solid" pos="right" rows="1" />
  </v-borders>
  <h-borders>
    <h-border row="0" col="0" color="Black" style="Solid" pos="top" cols="1" />
    <h-border row="1" col="0" color="Black" style="Solid" pos="bottom" cols="1" />

Why does it say col="1" on last v-borders row and row="1" on last h-border row? All the borders are in row 0 and col 0...

If I create a full border on A:1 and B:2

  <v-borders>
    <v-border row="0" col="0" color="Black" style="Solid" pos="left" rows="1" />
    <v-border row="0" col="1" color="Black" style="Solid" pos="all" rows="2" />
    <v-border row="1" col="2" color="Black" style="Solid" pos="right" rows="1" />
  </v-borders>
  <h-borders>
    <h-border row="0" col="0" color="Black" style="Solid" pos="top" cols="1" />
    <h-border row="1" col="0" color="Black" style="Solid" pos="all" cols="2" />
    <h-border row="2" col="1" color="Black" style="Solid" pos="bottom" cols="1" />

Where did col="2" come from on the last v-borders row? And what about row="0" col="1"....pos="all"...
Row="2"?

I can't make any sense and order out of how it is arranged. Should I combine the v-borders and h-borders somehow, or how is it all working?

Offline

#2 2015-12-28 00:57:29

Jingwood
Moderator
From: jing at reogrid.net
Registered: 2014-06-03
Posts: 615

Re: RGF and v-border and h-borders, can't make any sense out of it...

V-borders and H-borders are respectively stored in two 2D arrays. ReoGrid borders don't associate to cells.

Two neighbor cells A1 and B1 contain 3 v-borders (left, center, right) and 2 h-borders (top, bottom), simply count the borders on screen:

|  A1  |  B1  |
0      1      2
There is 3 v-borders.
0 ------------ 
   A1  |  B1 
1 ------------
There is 2 h-borders.

Border at center of A1 and B1 is shared border, in fact, it should be only one border there, it's why ReoGrid doesn't manage borders around cells. So forget borders around cells.

   A1  |  B1

In a worksheet, h-borders and v-borders separately stored in two 2D arrays.

For a single cell A1, borders stored in arrays like:
331.png

The rows and cols are the span if v-borders or h-borders that have same styles repeatedly appear in a column, or row.

In your second example, borders on screen like this:

+------+
|  A1  |
+------+------+
       |  B2  |
       +------+

So simply count the h-borders on screen:

--------
   A1   
---------------
          B2   
       --------

There is 3 h-borders, and [1,0] h-border appears two times, it's cols=2. Same to the v-borders.

For the pos attribute, it's more complex to calculate, you could just simply ignore this attribute, it only used when copying borders from worksheet.

If your another program which can use ReoGrid, I strongly suggest that you use memory workbook, call API to set borders and save the worksheet to generate a RGF file in memory or file, since manually generate this RGF borders XML that is actually difficult.
https://reogrid.net/document/workbook/
Section 'Memory Workbook'

Last edited by Jingwood (2015-12-29 00:28:01)

Offline

#3 2015-12-28 22:38:51

h3nrik
Member
Registered: 2015-12-27
Posts: 2

Re: RGF and v-border and h-borders, can't make any sense out of it...

Awesome! Thank you very much. All pieces of the puzzle are in place smile

Offline

Board footer

Powered by FluxBB