Sparklines en Aspose.Cells for .NET

Original: “Aspose.Cells is a .NET library for working with spreadsheet files that supports creating sparklines — miniature charts placed inside worksheet cells. This article explains how to add and customize line, column, and win/loss sparklines using the Aspose.Cells library.” “Introduction” - “Introducción” “Sparklines are tiny in-cell charts that are useful when you want to display a quick trend next to a row or column of data without taking up the space of a full chart. Excel supports three kinds of sparklines: line, column, and win/loss. Aspose.Cells mirrors this capability through the SparklineGroup and SparklineGroupCollection APIs found in the Aspose.Cells.Charts namespace.” “Line Sparklines” - “Sparklines de línea” “Column Sparklines” - “Sparklines de columna” “Win/Loss Sparklines” - “Sparklines de ganancia/pérdida” “Combining All Three Sparkline Types” - “Combinar los tres tipos de sparklines” “Customizing Sparkline Appearance” - “Personalizar la apariencia de los sparklines”

  1. Create a new Workbook and access the first worksheet.
  2. Populate a row of source data (for example, row 1, columns A through E) with the values you want to visualize.
  3. Build a CellArea describing the destination cell where the sparkline will be drawn.
  4. Call worksheet.SparklineGroups.Add(…). The third argument — false — tells Aspose.Cells that the data range is horizontal (a row), not vertical (a column).
  5. Optionally customize the returned SparklineGroup. For a line sparkline you can set the line color using group.Line.Color (which expects a CellsColor from Aspose.Cells.Drawing), adjust the line weight, and toggle high/low point markers.
  6. Save the workbook. That’s 1-6 sequential, good. Column sparklines:
  7. Create a new Workbook and access the first worksheet.
  8. Build a CellArea describing the destination cell.
  9. Call worksheet.SparklineGroups.Add(SparklineType.Column, “A1:E1”, false, dest).
  10. Optionally customize the resulting SparklineGroup — for example, by setting group.Type to confirm the type, or by tweaking the bar color.
  11. Save the workbook to a separate output file so it does not overwrite the line sparkline example. That’s 1, 3, 4, 5, 6. I’ll renumber to 1, 2, 3, 4, 5. Win/Loss:
  12. Create a new Workbook and access the first worksheet.
  13. Populate the source range…
  14. Build a CellArea…
  15. Call worksheet.SparklineGroups.Add(SparklineType.Stacked, “A1:E1”, false, dest).
  16. Optionally customize the returned SparklineGroup…
  17. Save the workbook under a distinct filename so all three examples can coexist on disk. That’s 1-6 sequential, good. Related Articles - I need to translate the titles.

Artículos Relacionados