We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

To find the row and column index

Hi,


I know the x, y position of a object in a sheet. I would like to find the corresponding row and column index of the sheet. How can i do that?

Example,

x -> 160, y -> 34

Regards,
Santhosh

Hi,

I am not sure about your requirement. Could you elaborate more and explain which object you are talking about.
For a Shape object, you may utilize some methods for the corresponding row and column, e.g
getLowwerRightColumn
getLowerRightRow
getUpperLeftColumn
getUpperLeftRow etc.

Thank you.

Hi,


Am creating a xls/ods file using your API. I want to insert an Image object. I want to set the position of this image. Using your api, i have to give the cell position(row, column). But i don’t know the row/col position. But i know the left and top of the that image. How do i set that image in my desired location.

Example,

Using the following code i have created an image.

InputStream is = new FileInputStream(file);
com.aspose.cells.Picture picture = shapes.addPicture(2, 2, is);

Here first two param(2, 2) shows the row and col position. But i would like to create an image with left and top values.

Regards,
Santhosh

Hi,

I am not sure what do you mean by left and top of the image, could you elaborate, so that we can understand you.

Thank you.

Hi,


I have inserted a image into a ods file using the below code.

com.aspose.cells.Picture picture = shapes.addPicture(2, 2, is); //Here 2, 2, is row and column

Now that inserted image was placed in the 2nd row, 2nd col of the document.

//Considered row height as 18 and column width is 80
Hope you know that,
starting cell of the spreadsheets position is (0,0)
postion of the cell which is in second row and first col is (18, 0)
position of the cell which is in second row and second col is(18, 80)

is there any api to insert Image by giving the positions like mentioned above.

For example,

com.aspose.cells.Picture picture = shapes.addPicture(18, 80, is); this should insert the image in the position 2nd row and 2nd column of the sheet.

Regards,
Santhosh




Hi,

Do you need to put/fit the image into a cell (e.g B2) with 18 pix height and 80 pix width?
Kindly create a simple Excel file (manually create in MS Excel) with your sample image inserted at your desired location in the sheet with your desired height/width, post the file here, we will let you know how you can make it by using the Aspose.Cells APIs.

Thank you.

Hi,

We are a browser based spreadsheet application.
I have attached a document which contains an image in cell B2.
Now consider that, the image is some (200 px, 200px) distance from the start of the grid.

Our requirement:
Now if we want to move the image to cell F6, which is at a distance of 300px, 300px from the start of the grid.

Is there an api like this ? moveImage(300px, 300px) so that it would be positioned in the cell F6.

Moreover, is there an api to find the row and col position by giving the input as 300px, 300px.

Santhosh

Hi,

Thanks for the template file and providing us the details about your requirements.

Now, we understand your needs. Well, we do have some methods e.g Shape.setTopPositionInPixel, Shape.setLeftPositionInPixel, Shape.setTopPosition, Shape.setLeftPosition, Shape.move methods. But, these methods would set a picture at the distance offsetting from the row/column indices. But, I am not sure if these APIs would be more helpful for your need as you need to insert the picture at a distance specifying from the origin of the grid.

Sample code:

Workbook wb = new Workbook();
wb.open(“d:\files\image.ods”,FileFormatType.ODS );
Shape pic = wb.getWorksheets().getSheet(0).getShapes().get(0);
short a = 100;
short b = 1;
short c = 100;
pic.setTopPositionInPixel(1,a);
pic.setLeftPositionInPixel(b,c);
wb.save(“d:\files\outTemplateFile.ods”,FileFormatType.ODS);


We need to analyze your needs if we can implement it. Anyways, I have logged an issue with an id: CELLSJAVA-22971. against your requirements. We will investigate and look into it surely. We will get back to you soon.

Thank you.

Hi,

Please try the attached fix/version. Now we provide some useful APIs for getting/setting shape’s absolute position to the sheet: i.e.

Shape.getPositionX()/getPositionY()/setPositionXY(int x, int y)
where x/y are the distance(pixels) from the start of the grid.

Thank you.

Hi,


Thanks a lot for providing this API. But i can’t download this. Please help me.

Regards,
Santhosh.

Hi,

You need to open the forum thread and then you can download the attachment that I attached to my previous reply in the thread. Also, make sure that you have logged into the Aspose Site before opening the forum thread.
Here is the forum thread url, just click it to open the thread:
<a href="https://forum.aspose.com/t/131917

Kindly let us know if you still find any issue.

Thank you.

Hi,


I have logged into the aspose site. Am trying to download the attached zip file in this thread. But can’t.

One more suggestion. Now you are providing the api to set left and top position (Shape.getPositionX()/getPositionY()/setPositionXY(int x, int y)). But while creating chart/image itself, we can’t give the x-pos and y-pos

You are provinding api to add chart like,

addChart(int chartType, int upperLeftRow, int upperLeftColumn, int lowerRightRow, int lowerRightColumn)

My question is, why should i provide (row, column) position while creating the chart. Since i know the position(x, y) and (width, height).
So i suggest kindly provide api like below,

addChart(int chartType, int xpos, int ypos)
addChart(int chartType, int xpos, int ypos, int width, int height)

Correct me if am asking anything wrong?

Note : Am using your API to create/manipulate the charts and images. Am satisfied and very happy with your API and your quick responses for every forum posts. Thank you for that.

Regards,
Santhosh.

Hi,

Please make sure that your networking policies (enforced by your company or ISP) allow downloading ZIP attachments.

Could you try to download the file from here

For specifying chart/image x and y positions. Well you should simply add a chart or insert image first using the existing API, then you can specify its x/y positions for your need using the new API. e.g
chart.getChartShape().setPositionXY()


Thank you.





Hi,


I can’t download, using the link you have given. But I can download the previous versions (aspose-cells-2.4.2.1-java.zip posted here ) .But i can’t download this new version. While downloading i got the “Access denied” screen(I have attached the screenshot). Though am logged in, upon clicking the link which you have given, it shows the logged username as guest.

As you said,
For specifying chart/image x and y positions. Well you should simply add a chart or insert image first using the existing API, then you can specify its x/y positions for your need using the new API. e.g
chart.getChartShape().setPositionXY()”,

Yes, we can do that. In my case i don’t know the (row, col) position to insert chart. But i know the (xpos, ypos). Using that how can i add chart?

Regards,
Santhosh

Hi,

For:
"Yes, we can do that. In my case i don’t know the (row, col) position to
insert chart. But i know the (xpos, ypos). Using that how can i add
chart?"

Well, you can just add the chart at any row/column position, then you may move the chart shape to your desired absolute X/Y position in the sheet.


For your downloading issue, I can see that you do not login to Aspose site, you have logged in as “Guest” user. Please first open the site “www.aspose.com” then click “Sign In” to login with your valid account. Now, open your thread (this thread) then try.


Thank you.

The issues you have found earlier (filed as 22971) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.