Message-ID: <1537316726.7771.1711621378138.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_7770_1685036245.1711621378138" ------=_Part_7770_1685036245.1711621378138 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
In addition to Charts, ExcelApplication allows you to add the following drawi= ng objects to a worksheet:
Pictures
A picture is a JPEG, PNG, BMP, or GIF=
image that is inserted in the worksheet. A picture is represented by a Pic=
ture object.
A comment must be associated with a cell. Once created, comments may not= be moved between cells. To create a comment:
Use the property Cell.Comment to return a Comment object.
ExcelApplication xla =3D new ExcelApplication(); Workbook wb =3D xla.Create(); Worksheet ws =3D wb.Worksheets[0]; Cell cellB5 =3D ws.Cells["B5"]; Comment comm =3D cellB5.Comment;=20
Add text to the comment.
comm.Text =3D "Figures for March are projected.";=20
Specify the author of the comment.
comm.Author =3D "John Doe";=20
Set whether the comment will be visible when the document is opened = in Excel. By default, the comment will be hidden, and will be displayed onl= y if the user hovers over the comment's cell.
comm.Visible =3D true;=20
To modify the comment's display area, return its Shape object and se= t Shape properties, for example:
Shape commShape =3D comm.Shape; commShape.FillColor =3D oColor; commShape.FitToText =3D true;=20
Pictures in a worksheet are stored in the Pictures collection. To add a = picture to a worksheet:
Return a Pictures collection.
ExcelApplication xla =3D new ExcelApplication(); Workbook wb =3D xla.Create(); Worksheet ws =3D wb.Worksheets[0]; Pictures pics =3D ws.Pictures;=20
Create a Picture object from a JPEG, PNG, BMP, or GIF image and inse= rt it at a specified anchor in the worksheet. The anchor represents the pos= ition of the top-left corner of the picture in the worksheet.
string imgPath =3D @"c:\images\owlogo.jpg"; Anchor anch =3D ws.CreateAnchor(0, 7, 0, 0); Picture pic =3D pics.CreatePicture(imgPath, anch);=20
To modify the size, position, or formatting of a Picture, return its= Shape object and set Shape properties, for example:
Shape picShape =3D pic.Shape; picShape.Rotation =3D 45;=20
Excel's ready-made AutoShapes are represented by the Shapeclass. To crea= te an AutoShape:
Return a Shapes collection.
ExcelApplication xla =3D new ExcelApplication(); Workbook wb =3D xla.Create(); Worksheet ws =3D wb.Worksheets[0]; Shapes shps =3D ws.Shapes;=20
Create a shape of a specified type and insert it at an anchor in the= worksheet.
Anchor anch =3D ws.CreateAnchor(0, 7, 0, 0); Shape shpHeart =3D shps.CreateShape(ShapeType.Heart, anch);=20
The ShapeType class contains the Excel AutoShapes supported by ExcelWrit= er. The specified anchor represents the position of the top-left corner of = the shape in the worksheet.