protected void CreateStaticReport() { //Intiaalize workbook with xlsx file format Workbook workbook = new Workbook(); //Clear workbook's worksheets workbook.Worksheets.Clear(); //Insert new Worksheet in workbook and name it "New" Worksheet worksheet = workbook.Worksheets.Add("New"); //Insert dummy data in A8, A9 and A10 cells worksheet.Cells["A8"].PutValue(34); worksheet.Cells["A9"].PutValue(50); worksheet.Cells["A10"].PutValue(34); //Intialize Cell Area CellArea cellArea = new CellArea(); //Assign Cell Area boundaries cellArea.StartColumn = 0; cellArea.EndColumn = 0; cellArea.StartRow = 0; cellArea.EndRow = 0; //Add new Sparklines in worksheet's sparlines collection and Assign the area for it int index = worksheet.SparklineGroupCollection.Add(SparklineType.Column, worksheet.Name + "!A8:A10", true, cellArea); //Initalize Sparklines Group SparklineGroup group = worksheet.SparklineGroupCollection[index]; // change the color of the series if need CellsColor cellColor = workbook.CreateCellsColor(); cellColor.Color = Color.Orange; //Asign the group series color group.SeriesColor = cellColor; if (ddlFileVersion.SelectedItem.Value == "XLS") { ////Save file and send to client browser using selected format workbook.Save(HttpContext.Current.Response, "SparkLines.xls", ContentDisposition.Attachment, new XlsSaveOptions(SaveFormat.Excel97To2003)); } else { workbook.Save(HttpContext.Current.Response, "SparkLines.xlsx", ContentDisposition.Attachment, new OoxmlSaveOptions(SaveFormat.Xlsx)); } //end response to avoid unneeded html HttpContext.Current.Response.End(); }
public static void Run() { // Instantiate a Workbook // Open a template file Workbook book = new Workbook(sourceDir + "sampleUsingSparklines.xlsx"); // Get the first worksheet Worksheet sheet = book.Worksheets[0]; // Use the following lines if you need to read the Sparklines // Read the Sparklines from the template file (if it has) foreach (SparklineGroup g in sheet.SparklineGroupCollection) { // Display the Sparklines group information e.g type, number of sparklines items Console.WriteLine("sparkline group: type:" + g.Type + ", sparkline items count:" + g.SparklineCollection.Count); foreach (Sparkline s in g.SparklineCollection) { // Display the individual Sparkines and the data ranges Console.WriteLine("sparkline: row:" + s.Row + ", col:" + s.Column + ", dataRange:" + s.DataRange); } } // Add Sparklines // Define the CellArea D2:D10 CellArea ca = new CellArea(); ca.StartColumn = 4; ca.EndColumn = 4; ca.StartRow = 1; ca.EndRow = 7; // Add new Sparklines for a data range to a cell area int idx = sheet.SparklineGroupCollection.Add(SparklineType.Column, "Sheet1!B2:D8", false, ca); SparklineGroup group = sheet.SparklineGroupCollection[idx]; // Create CellsColor CellsColor clr = book.CreateCellsColor(); clr.Color = Color.Orange; group.SeriesColor = clr; // Save the excel file book.Save(outputDir + "outputUsingSparklines.xlsx"); Console.WriteLine("UsingSparklines executed successfully."); }
public static void Main(string[] args) { //ExStart:1 // The path to the documents directory. string dataDir = Aspose.Cells.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); //Instantiate a Workbook //Open a template file Workbook book = new Workbook(dataDir + "Book1.xlsx"); //Get the first worksheet Worksheet sheet = book.Worksheets[0]; //Use the following lines if you need to read the Sparklines //Read the Sparklines from the template file (if it has) foreach (SparklineGroup g in sheet.SparklineGroupCollection) { //Display the Sparklines group information e.g type, number of sparklines items Console.WriteLine("sparkline group: type:" + g.Type + ", sparkline items count:" + g.SparklineCollection.Count); foreach (Sparkline s in g.SparklineCollection) { //Display the individual Sparkines and the data ranges Console.WriteLine("sparkline: row:" + s.Row + ", col:" + s.Column + ", dataRange:" + s.DataRange); } } //Add Sparklines //Define the CellArea D2:D10 CellArea ca = new CellArea(); ca.StartColumn = 4; ca.EndColumn = 4; ca.StartRow = 1; ca.EndRow = 7; //Add new Sparklines for a data range to a cell area int idx = sheet.SparklineGroupCollection.Add(SparklineType.Column, "Sheet1!B2:D8", false, ca); SparklineGroup group = sheet.SparklineGroupCollection[idx]; //Create CellsColor CellsColor clr = book.CreateCellsColor(); clr.Color = Color.Orange; group.SeriesColor = clr; //Save the excel file book.Save(dataDir + "Book1.out.xlsx"); //ExEnd:1 }
public static void Run() { // ExStart:1 // The path to the documents directory. string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // Instantiate a Workbook // Open a template file Workbook book = new Workbook(dataDir + "Book1.xlsx"); // Get the first worksheet Worksheet sheet = book.Worksheets[0]; // Use the following lines if you need to read the Sparklines // Read the Sparklines from the template file (if it has) foreach (SparklineGroup g in sheet.SparklineGroupCollection) { // Display the Sparklines group information e.g type, number of sparklines items Console.WriteLine("sparkline group: type:" + g.Type + ", sparkline items count:" + g.SparklineCollection.Count); foreach (Sparkline s in g.SparklineCollection) { // Display the individual Sparkines and the data ranges Console.WriteLine("sparkline: row:" + s.Row + ", col:" + s.Column + ", dataRange:" + s.DataRange); } } // Add Sparklines // Define the CellArea D2:D10 CellArea ca = new CellArea(); ca.StartColumn = 4; ca.EndColumn = 4; ca.StartRow = 1; ca.EndRow = 7; // Add new Sparklines for a data range to a cell area int idx = sheet.SparklineGroupCollection.Add(SparklineType.Column, "Sheet1!B2:D8", false, ca); SparklineGroup group = sheet.SparklineGroupCollection[idx]; // Create CellsColor CellsColor clr = book.CreateCellsColor(); clr.Color = Color.Orange; group.SeriesColor = clr; // Save the excel file book.Save(dataDir + "Book1.out.xlsx"); // ExEnd:1 }