We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Custom property syncing issue in xls files

Dear there,

I attached an excel file which has many VBA projects which synced various fields that called some of the custom property, the file has .xls extension. I tried many times using Aspose cells to sync those values, but i didn’t get what I want; the values didn’t appear on the file.

Any help or suggestions ?

Best Regards!

Hi,


Thanks for providing us some details.

Do you need to execute macros/vba code by Aspose.Cells to extract values from different object’s attributes at runtime? well, I am afraid, the feature (run macros or vba codes in Excel template files) is not supported yet by Aspose.Cells APIs. However, we do support to create, manipulate or embed VBA codes/ macros to the workbook though. Also, could you elaborate which custom properties’ values you need to get, if you can do it using MS Excel features manually (without using VBA codes or so)? I think you may accomplish the task via Aspose.Cells APIs, so kindly provide complete details with your template file (you did not attach your template file to your post), we will check and help you soon.

Thank you.

Dear there,


Sorry , yes I missed to attach the file, Now please check it then ; I need to get all custom property values which is synced by VBA project.
Note: All the fields filled by custom properties values , so I need to take all of these values then I can set it again if that’s possible.


Best Regards!

Hi,


Thanks for providing us template file.

Please see the document on how to access and create, obtain value, or manipulate Custom document properties via Aspose.Cells APIs for your reference:
http://www.aspose.com/docs/display/cellsjava/Managing+Document+Properties

Thank you.

Thanks a lot ,

But I have two other questions ;
Is there a way to get custom property name which is assigned to some filed ; I got the value but I need to know the name of that’s custom property?
and Is there a way to know in which cell that custom property is assigned ?

Best Regards!


Hi,


Thanks for sharing further details.

Well, if you need to get named ranges as per the screenshot, you can access these from the Workbook.getWorksheets().getNames() collection. Also, you may use Name.getRefersTo() method to get the cell’s details on which the named range is defined. See the following sample code (using your template file) for your reference:
e.g
Sample code:

String filePath = “Supplier+Audit+%23+00001+%5b1%5d.xls”;

Workbook workbook = new Workbook(filePath);
NameCollection col = workbook.getWorksheets().getNames();

for (int i = 0; i < col.getCount(); i++)
{

Name nm = col.get(i);
System.out.println(nm.getText());
System.out.println(nm.getRefersTo());

}

Also, see the document on Named Ranges for your further reference:
http://www.aspose.com/docs/display/cellsjava/Named+Ranges

Thank you.

Dear there,


I didn’t get what am asking about ; My question is ; can I get the custom property names behind getting the synced values which were done by VBA . I need to get all those values and names

please check the attached image that shows all custom property name with default value.

I have another question ; am trying to get content of every cell in excel sheet ? Can I get them, if yes ; please share that method

Best Regards!

Hi,


I think you forgot to attach the screenshot (image), please attach it here, we will check it soon.

Regarding your other question, if the requirement is to access/process all cells in a Worksheet or a range, it is recommended to use Enumerator (Iterator for Java). Please check the following code segment that achieves your requirements efficiently.
e.g
Sample code:

[Java]
Workbook book = new Workbook(strFilePath);
Worksheet sheet = book.getWorksheets().get(0);
Cells cells = sheet.getCells();
Iterator iterator = cells.iterator();
while(iterator.hasNext())
{
Cell cell = (Cell)iterator.next();
System.out.println(cell.getStringValue());

}


Hope, this helps a bit.

Thank you.

Okay , I will check this code right now.


And yes sorry I missed to attach that image , but now I did in the last update. Please check and advise.

Best Regards!

Hi,


Thanks for the screenshot.

See the sample code below that scans all the custom document properties in the workbook to retrieve each property’s name and its value for your requirements:
e.g
Sample code:

Workbook workbook = new Workbook(“f:\files\Supplier+Audit+%23+00001+%5b1%5d.xls”);

//Retrieve a list of all custom document properties of the Excel file
CustomDocumentPropertyCollection customProperties =
workbook.getWorksheets().getCustomDocumentProperties();

for(int i = 0;i<customProperties.getCount();i++)
{
DocumentProperty customProperty = customProperties.get(i);
System.out.println("Name: " + customProperty.getName()+ " Value: " + customProperty.getValue());
}


Hope, this helps a bit.

Thank you.

Thanks a lot for the great response.


I have another question , is there a way to convert index to cell name; In other words from the index (11) to (B1) for example.


Best Regards!

Hi,


Well, you may map cell indices (row and column indexes) to cell’s name, please try using CellsHelper class’ static methods for your needs, see the document for your reference:
http://www.aspose.com/docs/display/cellsjava/How+to+get+Cell+Name+from+Row+and+Column+Indices

Thank you.