How to set font bold to each subtotal

Dear All,


How to set font bold to each subtotal (see enclosed xls, marked by yellow backcolor)…?

I made subtotal by using the following codes:

cells.Subtotal(ca, 0, ConsolidationFunction.Sum, new int[] { 2, 3, 4, 5, 6, 7, 8, 9 });

please help

thanks

Hi Winanjaya,


Thank you for contacting Aspose support.

Unfortunately, there isn’t any direct method to set the style to the subtotals, although you may opt to find the cells for the string “total” and apply the desired style to the fetched row. Please check the below provided source code snippet and attached resultant spreadsheet for your reference.

C#

string file = myDir + “input.xlsx”;
var book = new Workbook(file);
var sheet = book.Worksheets[“Loss Ratio”];

var style = book.Styles[book.Styles.Add()];
style.Font.IsBold = true;
var styleFlag = new StyleFlag();
styleFlag.FontBold = true;

var opts = new FindOptions();
opts.LookInType = LookInType.Values;
opts.LookAtType = LookAtType.Contains;
opts.CaseSensitive = false;

Row row = null;
Cell current = null;
while ((current = sheet.Cells.Find(“total”, current, opts))!= null)
{
if (current != null)
{
row = sheet.Cells.Rows[current.Row];
row.ApplyStyle(style, styleFlag);
}
}

book.Save(myDir + “output.xlsx”, SaveFormat.Xlsx);

Hope this helps. Please feel free to write back in case you find any difficulty.