c# - Office Open for excel set single decimla place for percentage -


i using openxml creating excel document , want display percentage single decimal place percentage format "85.5%". not able find proper solution this.

following function create stylesheet.

private stylesheet generatestylesheet(numberingformat nf2decimal)     {         return new stylesheet(             new fonts(                 new font(new fontsize() { val = 11 }, new color() { rgb = new hexbinaryvalue() { value = "000000" } }, new fontname() { val = "calibri" }),                 new font(new bold(), new fontsize() { val = 12 }, new color() { rgb = new hexbinaryvalue() { value = "000000" } }, new fontname() { val = "calibri" }),                 new font(new bold(), new fontsize() { val = 11 }, new color() { rgb = new hexbinaryvalue() { value = "fccb02" } }, new fontname() { val = "calibri" }),                 new font(new bold(), new fontsize() { val = 11 }, new color() { rgb = new hexbinaryvalue() { value = "000000" } }, new fontname() { val = "calibri" }),                 new font(new italic(), new fontsize() { val = 11 }, new color() { rgb = new hexbinaryvalue() { value = "008000" } }, new fontname() { val = "calibri" }),                 new font(new bold(), new fontsize() { val = 14 }, new color() { rgb = new hexbinaryvalue() { value = "008000" } }, new fontname() { val = "calibri" })             ),             new fills(                 new fill(new patternfill() { patterntype = patternvalues.none }),                 new fill(new patternfill() { patterntype = patternvalues.gray125 }),                 new fill(new patternfill(new foregroundcolor() { rgb = new hexbinaryvalue() { value = "6e6e6e" } }) { patterntype = patternvalues.solid }),                 new fill(new patternfill(new foregroundcolor() { rgb = new hexbinaryvalue() { value = "ffb3b3" } }) { patterntype = patternvalues.solid }),                 new fill(new patternfill(new foregroundcolor() { rgb = new hexbinaryvalue() { value = "b3ffb3" } }) { patterntype = patternvalues.solid }),                 new fill(new patternfill(new foregroundcolor() { rgb = new hexbinaryvalue() { value = "ffdb99" } }) { patterntype = patternvalues.solid }),                 new fill(new patternfill(new foregroundcolor() { rgb = new hexbinaryvalue() { value = "eaeaea" } }) { patterntype = patternvalues.solid })             ),             new borders(                 new border(new leftborder(), new rightborder(), new topborder(), new bottomborder(), new diagonalborder()),                 new border(new leftborder() { style = borderstylevalues.thick }, new rightborder() { style = borderstylevalues.thick }, new topborder() { style = borderstylevalues.thick }, new bottomborder() { style = borderstylevalues.thick }, new diagonalborder()),                 new border(new leftborder() { style = borderstylevalues.thin }, new rightborder() { style = borderstylevalues.thin }, new topborder() { style = borderstylevalues.thin }, new bottomborder() { style = borderstylevalues.thin }, new diagonalborder())                 , new border(new leftborder(), new rightborder(), new topborder(), new bottomborder(), new diagonalborder())             ),              new cellformats(             //0                 new cellformat() { fontid = 0, fillid = 0, borderid = 0 },             //1                 new cellformat(new alignment() { horizontal = horizontalalignmentvalues.center, vertical = verticalalignmentvalues.center, wraptext = true }) { fontid = 1, fillid = 0, borderid = 1, applyborder = true, },             //2                 new cellformat(new alignment() { horizontal = horizontalalignmentvalues.left, vertical = verticalalignmentvalues.center, wraptext = true }) { fontid = 3, fillid = 0, borderid = 2, applyfill = false, applyborder = true },             //3                 new cellformat(new alignment() { horizontal = horizontalalignmentvalues.left, vertical = verticalalignmentvalues.center, wraptext = true }) { fontid = 5, fillid = 6, borderid = 2, applyborder = true, applyfill = true },             //4                 new cellformat(new alignment() { horizontal = horizontalalignmentvalues.left, vertical = verticalalignmentvalues.center, wraptext = true }) { fontid = 2, fillid = 2, borderid = 2, applyfill = true, applyborder = true },             //5                 new cellformat(new alignment() { horizontal = horizontalalignmentvalues.center, vertical = verticalalignmentvalues.center, wraptext = true }) { fontid = 3, fillid = 0, borderid = 2, applyfill = false, applyborder = true },             //6                 new cellformat(new alignment() { wraptext = true }) { fontid = 0, fillid = 0, borderid = 2, applyfill = false, applyborder = true, applynumberformat = true, numberformatid = 3 },             //7                 new cellformat(new alignment() { wraptext = true }) { fontid = 0, fillid = 0, borderid = 2, applyfill = false, applyborder = true, applynumberformat = true, numberformatid = 10 },             //8                 new cellformat(new alignment() { wraptext = true }) { fontid = 0, fillid = 0, borderid = 2, applyfill = false, applyborder = true, applynumberformat = true, numberformatid = 9 },             //9                 new cellformat(new alignment() { wraptext = true }) { fontid = 4, fillid = 3, borderid = 2, applyfill = false, applyborder = true, applynumberformat = true, numberformatid = 3 },             //10                 new cellformat(new alignment() { wraptext = true }) { fontid = 4, fillid = 3, borderid = 2, applyfill = false, applyborder = true, applynumberformat = true, numberformatid = 9 },             //11                 new cellformat(new alignment() { wraptext = true }) { fontid = 4, fillid = 4, borderid = 2, applyfill = false, applyborder = true, applynumberformat = true, numberformatid = 3 },             //12                 new cellformat(new alignment() { wraptext = true }) { fontid = 4, fillid = 4, borderid = 2, applyfill = false, applyborder = true, applynumberformat = true, numberformatid = 9 },             //13                 new cellformat(new alignment() { wraptext = true }) { fontid = 4, fillid = 5, borderid = 2, applyfill = false, applyborder = true, applynumberformat = true, numberformatid = 3 },             //14                 new cellformat(new alignment() { wraptext = true }) { fontid = 4, fillid = 5, borderid = 2, applyfill = false, applyborder = true, applynumberformat = true, numberformatid = nf2decimal.numberformatid },             //15                 new cellformat(new alignment() { horizontal = horizontalalignmentvalues.left, vertical = verticalalignmentvalues.center, wraptext = true }) { fontid = 0, fillid = 0, borderid = 2, applyfill = false, applyborder = true },             //16                 new cellformat(new alignment() { vertical = verticalalignmentvalues.center, wraptext = true }) { fontid = 0, fillid = 0, borderid = 2, applyfill = false, applyborder = true, applynumberformat = true, numberformatid = 3 }             )          ); // return     } 

can please me?


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -