J
JMGonzalez
Hi to everyone,
I'm working in a project which involves excel automation. The project has
been done in visual studio .net 2003 and written in c++. The object library
I'm using is EXCEL9.OLB
The problem happens when I try to paste a picture in a worksheet passing
their size (height and witdh) as parameters and then resize the dimensions of
the cell to the current size of the picture. (The point is that after
insertion,the cell has the same size than the picture)
First of all I paste the picture matching the top left corner of the picture
with the top left corner of the desired cell:
VARIANT varLeft;
VARIANT varTop;
varTop = this->objReportXls->objRange->get_Top();
varLeft = this->objReportXls->objRange->get_Left();
LPDISPATCH shapeDisp =
this->objReportXls->objShapes->AddPicture(pictureFileName,1,1, (float)varLeft.dblVal,(float)varTop.dblVal,(float)width,(float)height);
this->objReportXls->objShape->AttachDispatch(shapeDisp);
Then, I resize the cell with my own functions which performs the
put_ColumnsWidth and put_RowHeight operations. They have been extensively
tested and work well.
this->AdjustColumnsWidth(...,(short)width);
this->AdjustRowsHeight(...,(short)height);
The result is a cell whose height is exactly the same than the picture's but
it is much wider than it. I guess that "Points" unit is not the same
horizontally than vertically.
What I need is a way to take the width of the picture and transform into the
appropriate "horizontal points" value to adjust the width of the cell. Do you
know any function or method to make it possible?
Thanks in advance
I'm working in a project which involves excel automation. The project has
been done in visual studio .net 2003 and written in c++. The object library
I'm using is EXCEL9.OLB
The problem happens when I try to paste a picture in a worksheet passing
their size (height and witdh) as parameters and then resize the dimensions of
the cell to the current size of the picture. (The point is that after
insertion,the cell has the same size than the picture)
First of all I paste the picture matching the top left corner of the picture
with the top left corner of the desired cell:
VARIANT varLeft;
VARIANT varTop;
varTop = this->objReportXls->objRange->get_Top();
varLeft = this->objReportXls->objRange->get_Left();
LPDISPATCH shapeDisp =
this->objReportXls->objShapes->AddPicture(pictureFileName,1,1, (float)varLeft.dblVal,(float)varTop.dblVal,(float)width,(float)height);
this->objReportXls->objShape->AttachDispatch(shapeDisp);
Then, I resize the cell with my own functions which performs the
put_ColumnsWidth and put_RowHeight operations. They have been extensively
tested and work well.
this->AdjustColumnsWidth(...,(short)width);
this->AdjustRowsHeight(...,(short)height);
The result is a cell whose height is exactly the same than the picture's but
it is much wider than it. I guess that "Points" unit is not the same
horizontally than vertically.
What I need is a way to take the width of the picture and transform into the
appropriate "horizontal points" value to adjust the width of the cell. Do you
know any function or method to make it possible?
Thanks in advance