Excel API Library for .NET - Sample Browser | Document Solutions | Win/Loss sparkline
[
フレーム]
Refer to the following example code to learn how to add a win/loss sparkline formula in Document Solutions for Excel. A win/loss sparkline utilizes bar charts to represent data and provides a visual representation of positive and negative values.
//create a new workbook
var workbook = new GrapeCity.Documents.Excel.Workbook();
var worksheet = workbook.ActiveSheet;
worksheet.Range["A1"].Value = "Employee Performance";
worksheet.Range["A2:F5"].Value = new object[,]
{
{"Team Member","Wk1","Wk2","Wk3","Wk4","Wk5"},
{"Pamela Nelson",5,1,7,5,8},
{"Gabriel Reed",1,2,4,2,9},
{"Christina Robbins",4,10,8,5,10}
};
worksheet.Range["H2"].Value = "Target (tasks per week):";
worksheet.Range["I2"].Value = 5;
worksheet.Range["G2"].Value = "SparkLine";
// Since the formula contains a dynamic array formula (B3:F3-$I2ドル), Formula2 needs to be used.
worksheet.Range["G3:G5"].Formula2 = "=WINLOSSSPARKLINE(B3:F3-$I2,1,,,ドル\"{showNegative:TRUE}\")";
worksheet.Range["A1:G1"].Merge();
worksheet.Range["A1"].Interior.Color = System.Drawing.Color.Purple;
worksheet.Range["A1"].Font.Color = System.Drawing.Color.White;
worksheet.Range["A1"].HorizontalAlignment = HorizontalAlignment.Center;
worksheet.Range["A1:G5"].Borders.LineStyle = BorderLineStyle.Thin;
worksheet.Range["A1:G2"].Font.Bold = true;
worksheet.Range["A1"].Font.Size = 15;
worksheet.Range["A2:G5"].Font.Size = 13;
worksheet.Range["H2:I2"].Font.Bold = true;
worksheet.Range["H2:I2"].Font.Size = 13;
worksheet.Range["A:F"].AutoFit();
worksheet.Range["1:5"].RowHeight = 25;
worksheet.Range["G1:H1"].ColumnWidth = 30;
worksheet.PageSetup.Orientation = PageOrientation.Landscape;
// Save to a pdf file
workbook.Save("WinLossSparkline.pdf");
' Create a new Workbook
Dim workbook As New Workbook
Dim worksheet = workbook.ActiveSheet
worksheet.Range("A1").Value = "Employee Performance"
worksheet.Range("A2:F5").Value = New Object(,) {
{"Team Member", "Wk1", "Wk2", "Wk3", "Wk4", "Wk5"},
{"Pamela Nelson", 5, 1, 7, 5, 8},
{"Gabriel Reed", 1, 2, 4, 2, 9},
{"Christina Robbins", 4, 10, 8, 5, 10}
}
worksheet.Range("H2").Value = "Target (tasks per week):"
worksheet.Range("I2").Value = 5
worksheet.Range("G2").Value = "SparkLine"
' Since the formula contains a dynamic array formula (B3:F3-$I2ドル), Formula2 needs to be used.
worksheet.Range("G3:G5").Formula2 = "=WINLOSSSPARKLINE(B3:F3-$I2,1,,,ドル""{showNegative:TRUE}"")"
worksheet.Range("A1:G1").Merge()
worksheet.Range("A1").Interior.Color = System.Drawing.Color.Purple
worksheet.Range("A1").Font.Color = System.Drawing.Color.White
worksheet.Range("A1").HorizontalAlignment = HorizontalAlignment.Center
worksheet.Range("A1:G5").Borders.LineStyle = BorderLineStyle.Thin
worksheet.Range("A1:G2").Font.Bold = True
worksheet.Range("A1").Font.Size = 15
worksheet.Range("A2:G5").Font.Size = 13
worksheet.Range("H2:I2").Font.Bold = True
worksheet.Range("H2:I2").Font.Size = 13
worksheet.Range("A:F").AutoFit()
worksheet.Range("1:5").RowHeight = 25
worksheet.Range("G1:H1").ColumnWidth = 30
worksheet.PageSetup.Orientation = PageOrientation.Landscape
' save to a pdf file
workbook.Save("WinLossSparkline.pdf")