[Solved] Position Images in Calc Spreadsheet
Posted: Wed Feb 19, 2014 6:39 pm
Hello everyone,
my problem lies with inserting greater aumounts(around 1000 pics) of images into a Calc spreadsheet. The inserting alone i figured out already, but the positioning just doesnt go well.
The code to inserting is rather wide spread in methods and not easy to post, but it works, i have seen it. I recap what i have learned about inserting:
Images cannot be inserted directly into the cells via TextContext like this
so im inserting them into a DrawPage (Til now I only inserted one, do I need a new DrawPage for every Image or can i insert all in one?)
Since the image has no relation to any cell now i need to set the exact pixel Position of the image.
To get the Position of the upper left corner of the cell which needs to visualy hold the image, i wrote following method:
The code probably will not give the exact position yet, but i can figure that out when my problem is solved, which is the BorderLine Property.
Obviously the Properties "LeftBorder" and "BottomBorder" exist in the C# Uno Api, but no values are returned.
Before I call the method with the distinct cell I fill the Spreadsheet an show it, where i can see that everything worked an the distinct cell even holds content.
My question is now, can anybody tell me if theres a better and faster way to postion the image or relate an image to a cell, or does anyone have the slightes idea why the BorderLine Values are allways 0.
Thx very much in advance, and best Regards.
my problem lies with inserting greater aumounts(around 1000 pics) of images into a Calc spreadsheet. The inserting alone i figured out already, but the positioning just doesnt go well.
The code to inserting is rather wide spread in methods and not easy to post, but it works, i have seen it. I recap what i have learned about inserting:
Images cannot be inserted directly into the cells via TextContext like this
Code: Select all
var text = (XText)cell;
var xTextCursor = text.createTextCursor();
var xTextContent = (XTextContent)img;
text.insertTextContent(xTextCursor, xTextContent, true);
Since the image has no relation to any cell now i need to set the exact pixel Position of the image.
To get the Position of the upper left corner of the cell which needs to visualy hold the image, i wrote following method:
Code: Select all
protected Point GetCellPosition(XCell cell)
{
var adress = ((XCellAddressable)cell).getCellAddress();
var xRange = (XColumnRowRange)DocumentProperties.CurrentSheet.getCellRangeByPosition(0, 0, adress.Column, adress.Row);
var columns = xRange.getColumns();
var rows = xRange.getRows();
var pos = new Point(0, 0);
for (var i = 0; i < adress.Column; i++)
{
var column = columns.getByIndex(i);
var xprop = (XPropertySet)column.Value;
var bot = (BorderLine)xprop.getPropertyValue("BottomBorder").Value;
pos.X += bot.LineDistance;
}
for (var i = 0; i < adress.Row; i++)
{
var row = rows.getByIndex(i);
var xprop = (XPropertySet)row.Value;
var left = (BorderLine)xprop.getPropertyValue("LeftBorder").Value;
pos.Y += left.LineDistance;
}
return pos;
}
Obviously the Properties "LeftBorder" and "BottomBorder" exist in the C# Uno Api, but no values are returned.
Before I call the method with the distinct cell I fill the Spreadsheet an show it, where i can see that everything worked an the distinct cell even holds content.
My question is now, can anybody tell me if theres a better and faster way to postion the image or relate an image to a cell, or does anyone have the slightes idea why the BorderLine Values are allways 0.
Thx very much in advance, and best Regards.