42
Views
6
Comments
Solved
[Advanced Excel] Format cell as "Text"
advanced-excel
Service icon
Forge component by Carlos Freitas
Application Type
Reactive
Service Studio Version
11.54.30 (Build 62899)

Hi,

First of all, very nice component. I use it a lot and it works great!

I have now run into a small issue. I am using the Cell_Write activity to write a text value into a cell. In the action you can configure the CellType. In the description it mentions to use Text as the default cell type. But if I check the value in the outputted Excel file I see that the cell type is "General". 

Small explanation on why: I write values for material numbers to a column and those number are format "text". Three examples of numbers are: 7890, 007890, 007890A. Because these materials numbers can contain a letter it is formatted as Text. In this very specific use case (I know) they sometimes manually insert a row afterwards. If you insert a row, it takes over the formatting of the other row. If you would then type in a new material number like 007890 the difference is the following:

- Cell-type Text:  It will stay 007890

- Cell-type General: It will automatically convert to 7890 (not correct).

That is why I was wondering how can I configure the action to make sure the in the outputted Excel the cell type of a specific cell is Text instead of General?

Thanks!

Regards,

Teun

 
MVP
Solution

Hi Teun

I'm uploading a new version that will solve your challenge.

There are actually two ways to achieve what you want:

  1. Set the number format for the cell to "@".
  2. Using the new version of the component, set the CellType="text", because now the updated code correctly considers the CellType = "text" option and applies the desired NumberFormat to the cell, which is "@".

I've also update the sample app to show both options work the same, and included the "old" way of not setting a cell type, which would just leave the type as General.

Hope this helps.

Hanno

 
MVP

Hi Teun

Thanks for posting this question here.

That is certainly not ideal. I'll have a look at the code to see why it could be having that undesired effect.

Hanno

Thanks, really appreciate it!

 
MVP
Solution

Hi Teun

I'm uploading a new version that will solve your challenge.

There are actually two ways to achieve what you want:

  1. Set the number format for the cell to "@".
  2. Using the new version of the component, set the CellType="text", because now the updated code correctly considers the CellType = "text" option and applies the desired NumberFormat to the cell, which is "@".

I've also update the sample app to show both options work the same, and included the "old" way of not setting a cell type, which would just leave the type as General.

Hope this helps.

Hanno

Hi Hanno,

Thanks for the quick reply and solution.

I have applied option 1 for a short term solution currently and it works.

Updating to the new version is the next step but there are dependencies there to be checked first. I will update here if that is also working.

I really appreciate the quick action!

Teun 

Hi Teun,

Firstly, thank you for a well explained question!

I would wait for Hanno's response, but in the meantime, I have a suggestion.

Would it be acceptable to add an apostrophe to the start of the number? This won't appear in Excel, but will make Excel show the full value.

I hope this helps!

Kind regards,

Stuart

Hi Stuart,

Thanks for the suggestion. In this case it will not be the ideal solution. As a manual action the user can always change the cell type of the whole column to "Text" and work from there. But in case he forgets issues will occur in the follow up actions that are performed with the excel file. That is why I am looking into setting the Cell Type to "Text" from the forge component.

I did try to just add a ' in front of the material number (in the expression in OutSystems) but off course then it is just displaying ' in front of all materials.

Thanks for the efforts.

Regards,

Teun

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.