Xbasic
Office Example: Spreadsheet with picture
Description
This example creates a simple spreadsheet and adds a picture to the workbook, then sets the picture into a cell of the spreadsheet
dim DocumentFile as C = "c:\temp\flower.xlsx" dim Doc as office::ExcelDocument Dim Sheet as Office::Spreadsheet dim Picture as B dim Id as N 'Here we add a picture from a blob (first loading the file from disk) 'Note: This example shows how to set a blob containing a picture into a workbook. 'You could also call Doc.AddPicture(FileName), but then we couldn't show you ' how to load a picture from a blob. Picture = File.To_Blob(a5.get_exe_path(( \ + "\Samples\WebAppServerDemo\Hires\Daffodils.jpg"( Id = Doc.AddPicture(Picture( Sheet = Doc.AddSheet("Picture"( Sheet.SetPicture(1,1,Id( Path = File.FileName_Parse(DocumentFile, "P"( on error resume next File.Dir_Create(Path( on error goto 0 if Doc.Save(DocumentFile( 'Release all references to the document so we can open it in Excel delete Doc Sys_Open(DocumentFile( else UI_Msg_Box("Error Saving Document", \ "Unable to save document to " \ + DocumentFile + ":" + crlf(2( + Doc.ErrorMessage( end if
See Also
- Office
- Generate Excel Spreadsheets Programmatically
- Office::ExcelDocument
- Office::Excel2003Document
- Office::SpreadSheet
- Office::Format
- Office::Font
- Office Enumerations
- How to perform common spreadsheet operations
- Office Example: Hello, World Spreadsheet
- Office Example: Simple Weekly sales spreadsheet
- Office Example: Multiple spreadsheets
- Office Example: Spreadsheet from SQL query
- Office Example: Spreadsheet from DBF tables
- Office Example: Update a spreadsheet
- SQL Example: Spreadsheets from SQL schema