MiniExcel icon indicating copy to clipboard operation
MiniExcel copied to clipboard

How to trigger Excel's automatic calculation before saving

Open zhaofenglee opened this issue 1 year ago • 5 comments

Excel Type

  • [ ] XLSX

MiniExcel Version

1.33.0

Description

Export Excel through Stream, Excel contains formulas, but the cells with formulas do not display content when opened.

 var memoryStream = new MemoryStream();
                await memoryStream.SaveAsByTemplateAsync(tplPath, value);
                memoryStream.Seek(0, SeekOrigin.Begin);

                return new RemoteStreamContent(memoryStream, $"{DateTime.Now.ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture)}.xlsx",
	                "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

image

zhaofenglee avatar Jul 18 '24 03:07 zhaofenglee

Hi @zhaofenglee ,

try prefixing the formulas with $ like $=AVERAGE(D10:D119)

More info here

meld-cp avatar Jul 19 '24 23:07 meld-cp

Hi @meld-cp

A dollar sign ($) has been added in front of the formula. Here are the formulas that have been added. $=AVERAGE(D{{$enumrowstart}}:D{{$enumrowend}})

If you enable automatic calculation after editing, the formula is not a problem.

zhaofenglee avatar Jul 22 '24 06:07 zhaofenglee

Hi @zhaofenglee , so is this issue resolved? or may be I'm not understanding what the problem is 🤔

meld-cp avatar Jul 22 '24 11:07 meld-cp

Hi @meld-cp

The issue of updating the program to version 1.34.0 has not been resolved yet. Currently, the usage scenario is to download Excel through API or send Excel via email. By opening Excel in this way, it will display a protected view, causing formula cells to appear blank. If editing is enabled, the display will be normal. The expected result is to display the values of cells with formulas in a protected view. Is there any solution available to solve this?

zhaofenglee avatar Jul 23 '24 00:07 zhaofenglee

I also encountered this issue

luoxy123 avatar Aug 21 '24 08:08 luoxy123

@zhaofenglee , @luoxy123 I'm afraid this issue is not solvable. When a formula is written inside a cell it's the Excel engine that performs the calculations and caches the result. MiniExcel, being a simple lightweight data reader and writer cannot possibly do that, it's way beyond its scope.

michelebastione avatar Mar 21 '25 18:03 michelebastione