SetCustomProperty

Hi Adrian

I can't get SetCustomProperty to work - no error or anything, the custom property just isn't created. I've tried calling the workbook SetCustomProperty directly, and also used a TDocumentProperties.

If I create a custom workbook property using Excel then I can read it using Flexcel. All other aspects of my Flexcel workbooks are saving correctly so it's not clear what's going on. Do you have an example of usage?

Thanks, Bob

Hi,

Is the file you are creating an xlsx file?  FlexCel doesn't set custom properties in xls files.

Other than that, it should just work, and APIMate should tell you as usual the code. I just tried it here by creating a new Excel file and setting a custom property, then opening it in APIMate.  I got this code:



  //Custom Document Properties - Only for xlsx files
  xls.DocumentProperties.SetCustomProperty('tomato', TDocumentCustomPropertyType.String, 'red', 2);




I tried the code here in an empty file, and indeed it creates the property. (remember, only if you save as xlsx).
If it still doesn't work, do you have an idea of what you might be doing differently?
Sorry Adrian - my bad - a classic side-effect blunder in a setter in an old bit of code. I did notice however that when I call SetCustomProperty twice with the same property name, e.g. "WorkbookType", but different values it adds two "WorkbookType" nodes to the custom.xml with the two different values - is that expected?

Thanks, Bob