119
Views
14
Comments
Solved
[Advanced Excel] How to write a cell preserving its format?
Question
advanced-excel
Service icon
Forge asset by Carlos Freitas
Application Type
Service

Hello,

I need to work in a scenario:

  • read a predefined Excel file
  • treat it as a template, i.e. replace values in some cells but preserving their formatting
  • download the resulting file

Cell_Write with no format provided overwrites the existing format (but not completely: italics remain italics :-) ).

So, is it possible?

Regards

Tomasz

2025-09-25 22-50-38
Hanno
Solution

I've added a non-mandatory parameter to Cell_Write that allows you to preserve the formatting already applied to the cell.

This is now available in the latest version and will resolve your issue, @Tomasz M Lipinski 

2024-11-07 03-28-42
Stuart Harris
Champion

Hello Tomasz,

I use this component often and it seems to write into cells without overriding the format for me. I've used it to write text into cells with different coloured text, fonts and font sizes, bold, with different types of borders.

Can you be more specific about which formats are being removed? Also a screenshot or two showing your code and the properties panel of the Cell_Write action would help.

Kind regards,

Stuart

UserImage.jpg
Tomasz M Lipinski

Hello Stuart,

Please, find attached files:

  • Template.xlsx
  • Results.xlsx

The template: cells containing texts like {<name>} are placeholders - to be filled with data by the processing application. 

The results: I've added comments, which formatting has been preserved and which - lost. As you can see, some format attributes are preserved, some - lost.

Below is the core part of the action that fills the results file:

Regards

Tomasz

Results.xlsx
Template.xlsx
2024-11-07 03-28-42
Stuart Harris
Champion

Hi Tomasz,

I gave it a try with that template. I found that the bold formatting is removed. But strangely the right justification wasn't.

2025-09-25 22-50-38
Hanno

Good pickup, Stuart

I believe the challenge here is that the Bold setting, among a few others, are of type boolean, and that means if you don't supply a value for it, it gets set to false.

It may make sense to have a Cell_Write action that preserves the formatting by not having formatting as an input parameter, e.g. public void MssCell_Write(object ssWorksheet, string ssCellName, int ssCellRow, int ssCellColumn, string ssCellValue, string ssCellType)

Thoughts?

2025-09-25 22-50-38
Hanno

I've created an issue to track it https://github.com/HannoCoetzee/outsystems_advancedexcel/issues/18

2024-11-07 03-28-42
Stuart Harris
Champion

Hi Hanno, I agree with having Cell_Write without formatting. I suspect that will resolve the issue.

Kind regards,

Stuart

2025-09-25 22-50-38
Hanno
Solution

I've added a non-mandatory parameter to Cell_Write that allows you to preserve the formatting already applied to the cell.

This is now available in the latest version and will resolve your issue, @Tomasz M Lipinski 

UserImage.jpg
Tomasz M Lipinski

Hi,

Good job! Yes, this is exactly what I meant :-)

Regards

Tomasz

UserImage.jpg
virat kohli

@Hanno , I am facing the same problem, what non mandatory parameter you have added. The sahred link has no content

2025-09-25 22-50-38
Hanno

Hi @virat kohli 

The parameter is called PreserveFormat and should be available on the Cell_Write action.

Hanno

2024-11-05 11-28-22
Sunil Rajput

Hello

  I am share OML Kindly check this and resolve issue  Advance screen

AAAAAAAAPractice Advance.oml
UserImage.jpg
Tomasz M Lipinski

Hello,

But this OML seems only reading an Excel (Advance.SaveOnClick), not writing.... So it doesn't address my issue. Unless I've missed something...

Regards

Tomasz

2024-11-05 11-28-22
Sunil Rajput

Hii

Kindly This check

AAAAAAAAPractice Advance.oml
UserImage.jpg
Tomasz M Lipinski

Hi,

First, the OML misses "Forgecomponent" and "Testing" modules.

Second, the examples are about writing complete cell content. But my issue is: how to write a new content preserving the existing formatting?

As you could see in other parts of this discussion, even authors can see that this is an issue that should be solved inside the Advanced Excel component.

Regards

Tomasz

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