Module: Asposecellsjava::Document
- Defined in:
- lib/asposecellsjava/document.rb
Instance Method Summary collapse
- #add_custom_property ⇒ Object
- #get_properties ⇒ Object
- #initialize ⇒ Object
- #remove_custom_property ⇒ Object
Instance Method Details
#add_custom_property ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/asposecellsjava/document.rb', line 30 def add_custom_property() data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/' # Instantiating a Workbook object by excel file path workbook = Rjb::import('com.aspose.cells.Workbook').new(data_dir + 'Book1.xls') # Retrieve a list of all custom document properties of the Excel file #custom_properties = Rjb::import('java.util.ArrayList').new custom_properties = workbook.getWorksheets().getCustomDocumentProperties() # Adding a custom document property to the Excel file custom_properties.add("Publisher", "Aspose") # Save the document in PDF format workbook.save(data_dir + "Add_Property.xls") puts "Added custom property successfully." end |
#get_properties ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/asposecellsjava/document.rb', line 14 def get_properties() data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/' # Instantiating a Workbook object by excel file path workbook = Rjb::import('com.aspose.cells.Workbook').new(data_dir + 'Book1.xls') # Retrieve a list of all custom document properties of the Excel file custom_properties = workbook.getWorksheets().getCustomDocumentProperties() # Accessng a custom document property by using the property index puts "Property By Index: " + custom_properties.get(1).to_string # Accessng a custom document property by using the property name puts "Property By Name: " + custom_properties.get("Publisher").to_string end |
#initialize ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/asposecellsjava/document.rb', line 3 def initialize() # Accessing Document Properties get_properties() # Adding Custom Property add_custom_property() # Removing Custom Properties remove_custom_property() end |
#remove_custom_property ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/asposecellsjava/document.rb', line 49 def remove_custom_property() data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/' # Instantiating a Workbook object by excel file path workbook = Rjb::import('com.aspose.cells.Workbook').new(data_dir + 'Book1.xls') # Retrieve a list of all custom document properties of the Excel file custom_properties = workbook.getWorksheets().getCustomDocumentProperties() # Adding a custom document property to the Excel file custom_properties.remove("Publisher") # Save the document in PDF format workbook.save(data_dir + "Removed_Property.xls") puts "Removed custom property successfully." end |