Reply to topic  [ 4 posts ] 
Row and Col span when adding a chart to a sheet 
Author Message

Joined: Wed Oct 01, 2008 4:19 am
Posts: 10
Reply with quote
Post Row and Col span when adding a chart to a sheet
Hi,

Is there any way of know how many lines a chart spans across a sheet rows and/or columns.

For example, suppose I need to add information to a sheet after adding a chart, with 600x300 (widthxheight), how many lines (and/or columns) should I assume the chart will use?


I've tried:
Code:
ExcelChart chart = new Chart(0, 0, 600, 300);
//... some specific code



        ExcelTable xlsTable = sheet.easy_getExcelTable();
       
        int h = 0, hRows = 0;
        while (h < height) {
            if (hRows <xlsTable> -1) {
                h += xlsTable.easy_getRowAt(hRows).getHeight();
            } else {
//                h += xlsTable.getRowHeight(); // THIS DOESN'T WORK
                h += 16; // ASSUMING, Row hight is 16px
            }
            hRows++;

        }
       
        int w = 0, wColumns = 0;
        while (w < width) {
            if (wColumns <xlsTable> -1) {
                w += xlsTable.getColumnWidth(wColumns);
            } else {
                w +=  xlsTable.getColumnWidth();
            }
            wColumns++;
        }


(hRows it's the number of rows we should skip and wColumns the number of columns we should skip)

This doen't solve completly my problem. The results aren't correct.

Any ideas?


Thanks in advance
Regards


Wed Oct 01, 2008 4:44 am
Profile

Joined: Wed Nov 07, 2007 4:42 am
Posts: 67
Reply with quote
Post Row and Col span when adding a chart to a sheet
Hi,

The chart size is not variable. For adding a chart please use ExcelWorksheet.easy_addChart(ExcelChart xlsChart, int row, int column, int width, int height) method.


Thu Oct 02, 2008 5:58 am
Profile WWW

Joined: Wed Oct 01, 2008 4:19 am
Posts: 10
Reply with quote
Post 
Hi,

Thanks for you replay.

But you don't seem to see what is my problem.

Suppose i want to create the xls with this format:
<table border="1">
<tr>
<td width="100px">Text 1 </td>
<td width="100px">Text 2 </td>
<td width="100px"></td>
<tr>
<tr>
<td width="100px">-</td>
<td width="100px"></td>
<td width="100px"></td>
<tr>
<tr>
<td colspan="2" width="200px" height="200px">Image (600x300)</td>
<td width="100px">Text 3 </td>
<tr>
<tr>
<td width="100px">Text 4 </td>
<td width="100px"></td>
<td width="100px"></td>
<tr>
</table>

Using the API i know the columns for adding Text 1, Text 2, Text 3 and the Image.
But, when I try to add:

    Text 3 - don't know wich column should I address (row is the same given for the image)

    Text 4 - don't know wich row should I address (column is the same given for the image)


What I need is a way to convert (width, height) to (#columns, #rows).


Thanks


Thu Oct 02, 2008 8:32 am
Profile

Joined: Wed Oct 01, 2008 4:19 am
Posts: 10
Reply with quote
Post 
Hi,

Here's what I've found out for my problem:

Quote:
The default dimensions of a cell are: Length = 64 pixels, Height = 17 pixels.
Your chart dimensions are 600x300. In this case we suggest you to calculate the distance where your tables will be placed as follows:
- if you want to place them at the bottom of the chart do 300 / 17 = 17.64 (~18 = row number)
- if you want to place them on the right of the chart do 600 / 64 = 9.37 (~10 = column number)

If the length of the information inside your cells exceeds the default column length of 64 pixels, please set the column width manually, using setColumnWidth(int column,int columnWidth) method.


Hope this helps others.

Regards


Thu Oct 30, 2008 8:32 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.