protected override Dynamic Process() { Dynamic data = new Dynamic() { ["Code"] = 0, ["Data"] = null }; try { ExcelPackage p = _provider.GetService(typeof(ExcelPackage)) as ExcelPackage; int tableIndex = 0; do { IExcelSheet sheet = p.AddSheet("Sheet" + (++tableIndex)); int rowIndex = 0; int rStart = 2, cStart = 1; while (ReadLine()) { for (int colIndex = 0; colIndex < FieldCount; colIndex++) { IExcelRange range = sheet.Range(rStart + rowIndex, cStart + colIndex); range.Value = GetFieldValue(colIndex); } rowIndex++; } rStart = 1; for (int colIndex = 0; colIndex < FieldCount; colIndex++) { IExcelRange range = sheet.Range(rStart, colIndex + cStart); range.Value = GetFieldName(colIndex); IExcelColumn column = sheet.Column(colIndex + cStart); column.SetFormat(GetFieldType(colIndex)); column.AutoFit(); } } while (ReadNextResult()); data["Data"] = p.GetBytes(); p.Dispose(); } catch (Exception) { data["Code"] = 1; } return(data); }
/// <summary> /// Добавить круговую диаграмму. /// </summary> /// <param name="position">Положение левого верхнего угла.</param> /// <param name="name">Название.</param> /// <param name="size">Размер в пикселах.</param> /// <param name="valuesRange">Диапазон значений.</param> /// <param name="axesRange">Диапазон названий.</param> public void AddPieChart(IExcelCell position, string name, int size, IExcelRange valuesRange, IExcelRange axesRange) { var chart = (ExcelPieChart)_worksheet.Drawings.AddChart(name, eChartType.PieExploded3D); chart.SetPosition(position.Row, 0, position.Column, 0); chart.SetSize(size, size); chart.Series.Add(valuesRange.GetAddress(), axesRange.GetAddress()); chart.Title.Text = name; ApplyPieChartStyles(chart); }
public void AddRange(IExcelRange range, int row, int column) { _cells[new Tuple <int, int>(row, column)] = range; }