|
|
|
The Pictures Object (SAPictures)
* The Pictures object is not available in ExcelWriterSE, ExcelWriterLE,
or ExcelWriterFree.
The Pictures object is a collection, representing the set of all pictures in a single worksheet. To create a Pictures
object, use,
[VBScript]
Set Pictures = WrkSheet.Pictures
Pictures Methods and Properties
*This feature is not available in
ExcelWriterSE, ExcelWriterLE, or ExcelWriterFree.
| Pictures Methods and Properties |
| Count* |
Counts the number of pictures in a worksheet.
[VBScript]
Property Count As Long (read-only)
Example:
[VBScript]
'--- Create an instance of ExcelWriter and get a reference to worksheet #1
Dim XlwApp, WrkSht, PictureCnt
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
'--- Get a count of the number of pictures in the worksheet
PictureCnt = WrkSht.Pictures.Count
Response.Write "There are " & PictureCnt & " pictures."
Top |
| CreateFromFile* |
Creates a Picture
object from an existing image file.
CreateFromFile takes five parameters:
Pictures.CreateFromFile(UpperLeftColumn, UpperLeftRow, LowerRightColumn, LowerRightRow, FileName)
UpperLeftColumn, UpperLeftRow, LowerRightColumn, and LowerRightRow specify the
location of the picture in the worksheet. FileName specifies the complete path and
name of the file from which you are creating a picture.
Note: Setting the location in the worksheet
of two of the picture's corners may resize the image disproportionately,
distorting the image. To avoid image distortion, use
CreateFromFile2.
The following example demonstrates creating a picture object.
[VBScript]
Function CreateFromFile(UpperLeftColumn As Long, _
UpperLeftRow As Long, _
LowerRightColumn As Long, _
LowerRightRow As Long, _
FileName As String) As SAPicture
Example:
[VBScript]
'--- Create an instance of ExcelWriter and get a reference to worksheet #1
Dim XlwApp, WrkSht, PicPath, Pic
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
PicPath = "c:\temp\mypic.bmp"
'--- Use CreateFromFile to add a picture to a worksheet
'--- and specify its dimensions
'--- This picture's upper left corner will be at A1
'--- Its lower right corner at J10
Set Pic = WrkSht.Pictures.CreateFromFile(1,1,10,10,PicPath)
Top |
| CreateFromFile2* |
Creates a Picture
object from an existing image file.
CreateFromFile2 takes three parameters:
Pictures.CreateFromFile2(UpperLeftColumn, UpperLeftRow, FileName)
UpperLeftColumn and UpperLeftRow specify the location in the worksheet of the
image's top left corner. FileName specifies the complete path and
name of the file from which you are creating a picture.
[VBScript]
Function CreateFromFile2(UpperLeftColumn As Long, _
UpperLeftRow As Long, _
FileName As String) As SAPicture
Example:
[VBScript]
'--- Create an instance of ExcelWriter and get a reference to worksheet #1
Dim XlwApp, WrkSht, PicPath, Pic
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
PicPath = "c:\temp\mypic.bmp"
'--- CreateFromFile2 is simliar to CreateFromFile
'--- Except it is only necessary to specify the
'--- upper left corner. This avoids image distortion
'--- due to unproportional sizing
'--- This picture's upper left corner will be at A1
Set Pic = WrkSht.Pictures.CreateFromFile(1,1,PicPath)
Top |
| Item* |
Represents a single Picture object in a Pictures collection.
Item is the default property of Pictures, so Pictures(1) is equivalent to Pictures.Item(1). This collection is 1-based.
[VBScript]
In VBScript, this is the default property for the SAPictures object.
Property Item(Index As Long) As SAPicture (read-only)
Example:
[VBScript]
'--- Create an instance of ExcelWriter and get a reference to worksheet #1
Dim XlwApp, WrkSht, PicOne, PicTwo
Set XlwApp = Server.CreateObject("SoftArtisans.ExcelWriter")
Set WrkSht = XlwApp.Worksheets(1)
'--- Use the default Item property to get individual SAPictures
'--- in the Pictures collection. This collection is 1-based.
Set PicOne = WrkSht.Pictures(1)
Set PicTwo = WrkSht.Pictures(2)
Top |
| *This feature is not available in
ExcelWriterSE, ExcelWriterLE, or ExcelWriterFree.
|
Copyright © 2005, SoftArtisans, Inc.
|
|