Hi
Can I extract cell coordinates in pixels? I need to convert the *.xls file into image and get coordinates of each cell on this image.
Thank you for your help!
Hi
Hi,
I want to get the position of cells in the generated image from the worksheet by using ToImage or ToTiff. I calculated cells positions and sizes in the worksheet and found, that they don’t equal positions and sized in the generated image in actual size.
Hi Samsen,
Please try the following code for your reference:<o:p></o:p>
Sample code:
class MyDraw:DrawObjectEventHandler
{
Bitmap bit;
Graphics gr;
public MyDraw()
{
bit = new Bitmap(1200, 1200);
gr = Graphics.FromImage(bit);
gr.PageUnit = GraphicsUnit.Point;
}
public override void Draw(DrawObject drawObject, float x,float y,float width ,float height)
{
if(drawObject.Image != null)
gr.DrawImage(drawObject.Image, x,y,width,height);
if (drawObject.Cell != null)
{
gr.DrawString(drawObject.Cell.StringValue, new System.Drawing.Font("arial", 10), new SolidBrush(Color.Black),x,y);
}
}
}
ImageOrPrintOptions options = new ImageOrPrintOptions();
MyDraw md = new MyDraw();
options.DrawObjectEventHandler = md;
SheetRender sheetRender = new SheetRender(wb.Worksheets[0], options);
sheetRender.ToImage(0, @"e:\m\" + 0 + "" + ".png");
Thank you.
workSheet.Cells.GetViewColumnWidthPixel(j)
- with this I can get width.
workSheet.Cells.GetRowHeightPixel(i)
- with this I can get height.
Hi,
Okay Sahi, thanks it helped me.
Hi,