简体   繁体   中英

Maximum value for the absolute of Numbers in Excel and C# programatically

I am programming an application which uses data from excel file. in order to to get the maximum number in a range of column, I do the following:

 xlRng = sheetReal.Range[sheetReal.Cells[11, i], sheetReal.Cells[41, i]];
 sheetReal.Cells[UsedRow , i].Value = excelApp.WorksheetFunction.Max(xlRng);

which is fine. but now I want to have the maximum value for the absolutes of numbers. How can I get that?

Thank you

Change:

excelApp.WorksheetFunction.Max(xlRng);

To:

excelApp.WorksheetFunction.Max(-excelApp.WorksheetFunction.Min(xlRng), excelApp.WorksheetFunction.Max(xlRng));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM