private Row GenerateRowForProperty(UInt32Value rowIndex, int linesToAdd, ProjectFile projectFile, String property) { Row row = new Row() { RowIndex = (UInt32Value)(rowIndex + linesToAdd), Spans = new ListValue<StringValue>() { InnerText = "3:9" }, DyDescent = 0.25D }; ProjectProperty projectProperty = projectFile.ProjectProperties.FirstOrDefault(prop => prop.Type == property); if (projectProperty != null) { int sharedStringIndexForType = 0; for (int i = 0; i < SharedStrings.Count; i++) { if (SharedStrings[i].Text.Text == projectProperty.Type) { sharedStringIndexForType = i; break; } } List<Cell> cells = new List<Cell>() { new Cell(){CellReference = GetCell(String.Format("C{0}", rowIndex.Value), linesToAdd),StyleIndex = (UInt32Value) 7U,DataType = CellValues.SharedString, CellValue = new CellValue(sharedStringIndexForType.ToString(CultureInfo.InvariantCulture))}, new Cell(){CellReference = GetCell(String.Format("D{0}", rowIndex.Value), linesToAdd),StyleIndex = (UInt32Value) 8U,DataType = CellValues.Number, CellValue = new CellValue(projectProperty.Rate.ToString(CultureInfo.InvariantCulture))}, new Cell(){CellReference = GetCell(String.Format("F{0}", rowIndex.Value), linesToAdd),StyleIndex = (UInt32Value) 9U,DataType = CellValues.Number, CellValue = new CellValue(projectProperty.Words.ToString(CultureInfo.InvariantCulture))}, new Cell(){CellReference = GetCell(String.Format("G{0}", rowIndex.Value), linesToAdd),StyleIndex = (UInt32Value) 9U,DataType = CellValues.Number, CellValue = new CellValue(projectProperty.Characters.ToString(CultureInfo.InvariantCulture))}, new Cell(){CellReference = GetCell(String.Format("H{0}", rowIndex.Value), linesToAdd),StyleIndex = (UInt32Value) 9U,DataType = CellValues.Number, CellValue = new CellValue(projectProperty.ValueByWords.ToString(CultureInfo.InvariantCulture))}, new Cell(){CellReference = GetCell(String.Format("I{0}", rowIndex.Value), linesToAdd),StyleIndex = (UInt32Value) 9U,DataType = CellValues.SharedString, CellValue = new CellValue("15")} }; row.Append(cells.ConvertAll(c => (OpenXmlElement) c)); } return row; }
private void PrepareFilesList(String projectAnalyseFile) { ProjectFiles = new List<ProjectFile>(); var projectsFile = new XPathDocument(projectAnalyseFile); var nav = projectsFile.CreateNavigator(); const string expression = "task/file"; var projectNodes = nav.Select(expression); ProjectFile file; while (projectNodes.MoveNext()) { file = new ProjectFile(_template) { AnalyseFile = projectAnalyseFile, IsSummary = false, XMLNode = projectNodes.Current }; file.Prepare(); ProjectFiles.Add(file); } file = new ProjectFile(_template) { AnalyseFile = projectAnalyseFile, IsSummary = true, FileName = (new UIResources(Settings.GetSavedCulture())).Summary, XMLNode = nav.SelectSingleNode("task/batchTotal") }; file.Prepare(); ProjectFiles.Add(file); }
public override String GenerateHeader(ProjectFile file) { UIResources resources = new UIResources(Settings.GetSavedCulture()); StringBuilder sb = new StringBuilder(); sb.AppendLine("<TABLE><tbody>"); sb.AppendLine( String.Format( "<TR><TD><b>{0}</b></TD> <TD><b>{1}</b></TD> <TD><b>{2}</b></TD> <TD><b>{3}</b></TD> <TD><b>{4}</b></TD></TR>", resources.Type, resources.Rates, resources.Words, resources.Characters, resources.Value)); return sb.ToString(); }
private String GenerateJustLines(ProjectFile file) { UIResources resources = new UIResources(Settings.GetSavedCulture()); StringBuilder sb = new StringBuilder(); sb.AppendLine("<TABLE><tbody>"); sb.AppendLine(String.Format("<TR><TD><b>{0}</b></TD> <TD><b>{1}</b></TD></TR>", resources.Type.PadRight(30, ' '), resources.Rates)); foreach (var rate in AdditionalRates) { sb.AppendLine(String.Format("<TR><TD>{0}</TD> <TD>{1}</TD></TR>", rate.Type.PadRight(30, ' '), rate.Rate.ToString())); } sb.AppendLine("</tbody></TABLE>"); sb.AppendLine("<br>"); sb.AppendLine(resources.JustLines); sb.AppendLine("<br>"); sb.AppendLine("<TABLE><tbody>"); sb.AppendLine(String.Format("<TR><TD><b>{0}:</b></TD> <TD>{1} {2}</TD> <TD>{3} {4}</TD></TR>", resources.PaymentByCharacters, file.LinesByCharacters.ToString(), resources.StandardLines, file.ValueByLbC.ToString(), resources.Euros)); sb.AppendLine(String.Format("<TR><TD><b>{0}:</b></TD> <TD>{1} {2}</TD> <TD>{3} {4}</TD></TR>", resources.PaymentByKeystrokes, file.LinesByKeyStrokes.ToString(), resources.StandardLines, file.ValueByLbK.ToString(), resources.Euros)); sb.AppendLine("</tbody></TABLE>"); sb.AppendLine("<br>"); return sb.ToString(); }
public virtual String GenerateHeader(ProjectFile file) { return String.Empty; }
// Generates content of worksheet. protected override void GenerateWorksheetDataContent(SheetData sheetData, int linesToAdd, ProjectFile projectFile) { List<Row> rows = new List<Row>(); List<Cell> cells = new List<Cell>(); #region file name Row fileNameRow = new Row(){RowIndex = (UInt32Value)(2U + linesToAdd),Spans = new ListValue<StringValue>() { InnerText = "3:9" },DyDescent = 0.25D}; if (FileNamesSharedStrings == null) FileNamesSharedStrings = new List<SharedStringItem>(); FileNamesSharedStrings.Add(new SharedStringItem() { Text = new Text() { Text = String.Format("File: {0}", Path.GetFileName(projectFile.FileName)) } }); // ReSharper disable PossiblyMistakenUseOfParamsMethod fileNameRow.Append(new Cell() { CellReference = GetCell("C2", linesToAdd), StyleIndex = (UInt32Value)3U, DataType = CellValues.SharedString, CellValue = new CellValue((SharedStringsCount + FileNamesSharedStrings.Count).ToString(CultureInfo.InvariantCulture)) }); rows.Add(fileNameRow); // ReSharper restore PossiblyMistakenUseOfParamsMethod #endregion #region analysis results text Row arRow = new Row(){RowIndex = (UInt32Value) (3U+linesToAdd),Spans = new ListValue<StringValue>() {InnerText = "3:9"},DyDescent = 0.25D}; cells = new List<Cell>() { new Cell() {CellReference = GetCell("F3", linesToAdd), StyleIndex = (UInt32Value)1U, DataType = CellValues.SharedString, CellValue = new CellValue("0") }, new Cell() {CellReference = GetCell("G3", linesToAdd), StyleIndex = (UInt32Value) 1U}, new Cell() {CellReference = GetCell("H3", linesToAdd), StyleIndex = (UInt32Value) 1U}, new Cell() {CellReference = GetCell("I3", linesToAdd), StyleIndex = (UInt32Value) 1U} }; arRow.Append(cells.ConvertAll(c => (OpenXmlElement)c)); rows.Add(arRow); #endregion #region header row Row headerRow = new Row(){RowIndex = (UInt32Value) (4U+linesToAdd),Spans = new ListValue<StringValue>() {InnerText = "3:9"},DyDescent = 0.25D}; cells = new List<Cell>() { new Cell() {CellReference = GetCell("C4", linesToAdd), StyleIndex = (UInt32Value) 3U, DataType = CellValues.SharedString, CellValue = new CellValue("1")}, new Cell() {CellReference = GetCell("D4", linesToAdd), StyleIndex = (UInt32Value) 4U, DataType = CellValues.SharedString, CellValue = new CellValue("2")}, new Cell() {CellReference = GetCell("F4", linesToAdd), StyleIndex = (UInt32Value) 5U, DataType = CellValues.SharedString, CellValue = new CellValue("3")}, new Cell() {CellReference = GetCell("G4", linesToAdd), StyleIndex = (UInt32Value) 5U, DataType = CellValues.SharedString, CellValue = new CellValue("4")}, new Cell() {CellReference = GetCell("H4", linesToAdd), StyleIndex = (UInt32Value) 6U, DataType = CellValues.SharedString, CellValue = new CellValue("5")}, new Cell() {CellReference = GetCell("I4", linesToAdd), StyleIndex = (UInt32Value) 2U} }; headerRow.Append(cells.ConvertAll(c => (OpenXmlElement)c)); rows.Add(headerRow); #endregion #region value rows rows.Add(GenerateRowForProperty(5U, linesToAdd, projectFile, Templates.Templates.PerfectMatch)); rows.Add(GenerateRowForProperty(6U, linesToAdd, projectFile, Templates.Templates.ContextMatch)); rows.Add(GenerateRowForProperty(7U, linesToAdd, projectFile, Templates.Templates.Repetitions)); rows.Add(GenerateRowForProperty(8U, linesToAdd, projectFile, Templates.Templates.Percent100)); rows.Add(GenerateRowForProperty(9U, linesToAdd, projectFile, Templates.Templates.Percent95)); rows.Add(GenerateRowForProperty(10U, linesToAdd, projectFile, Templates.Templates.Percent85)); rows.Add(GenerateRowForProperty(11U, linesToAdd, projectFile, Templates.Templates.Percent75)); rows.Add(GenerateRowForProperty(12U, linesToAdd, projectFile, Templates.Templates.Percent50)); rows.Add(GenerateRowForProperty(13U, linesToAdd, projectFile, Templates.Templates.New)); rows.Add(GenerateRowForProperty(14U, linesToAdd, projectFile, Templates.Templates.Tags)); #endregion #region total rows Row emptyRow = new Row() { RowIndex = (UInt32Value)(15U + linesToAdd), Spans = new ListValue<StringValue>() { InnerText = "3:9" }, DyDescent = 0.25D }; cells = new List<Cell>() { new Cell() {CellReference = GetCell("F15", linesToAdd), StyleIndex = (UInt32Value) 12U}, new Cell() {CellReference = GetCell("G15", linesToAdd), StyleIndex = (UInt32Value) 12U}, new Cell() {CellReference = GetCell("H15", linesToAdd), StyleIndex = (UInt32Value) 12U}, new Cell() {CellReference = GetCell("I15", linesToAdd), StyleIndex = (UInt32Value) 12U} }; emptyRow.Append(cells.ConvertAll(c => (OpenXmlElement)c)); rows.Add(emptyRow); Row totalRow = new Row() { RowIndex = (UInt32Value)(16U + linesToAdd), Spans = new ListValue<StringValue>() { InnerText = "3:9" }, DyDescent = 0.25D }; Decimal totalWords = projectFile.ProjectProperties.Where(property => property.StandardType != StandardType.Global).Sum(property => property.Words); Decimal totalChars = projectFile.ProjectProperties.Where(property => property.StandardType != StandardType.Global).Sum(property => property.Characters); Decimal totalValue = projectFile.ProjectProperties.Where(property => property.StandardType != StandardType.Global).Sum(property => property.ValueByWords); cells = new List<Cell>() { new Cell(){CellReference = GetCell("F16", linesToAdd),StyleIndex = (UInt32Value) 13U, DataType = CellValues.Number, CellValue = new CellValue(totalWords.ToString(CultureInfo.InvariantCulture))}, new Cell(){CellReference = GetCell("G16", linesToAdd),StyleIndex = (UInt32Value) 13U, DataType = CellValues.Number, CellValue = new CellValue(totalChars.ToString(CultureInfo.InvariantCulture))}, new Cell(){CellReference = GetCell("H16", linesToAdd),StyleIndex = (UInt32Value) 13U, DataType = CellValues.Number, CellValue =new CellValue(totalValue.ToString(CultureInfo.InvariantCulture))}, new Cell(){CellReference = GetCell("I16", linesToAdd), StyleIndex = (UInt32Value) 13U ,DataType = CellValues.SharedString, CellValue = new CellValue("15")} }; totalRow.Append(cells.ConvertAll(c => (OpenXmlElement)c)); rows.Add(totalRow); #endregion sheetData.Append(rows.ConvertAll(c => (OpenXmlElement)c)); }
protected override void GenerateWorksheetDataContent(SheetData sheetData, int linesToAdd, ProjectFile projectFile) { List<Row> rows = new List<Row>(); List<Cell> cells = new List<Cell>(); #region file name Row fileNameRow = new Row() { RowIndex = (UInt32Value)(2U + linesToAdd), Spans = new ListValue<StringValue>() { InnerText = "3:9" }, DyDescent = 0.25D }; if (FileNamesSharedStrings == null) FileNamesSharedStrings = new List<SharedStringItem>(); FileNamesSharedStrings.Add(new SharedStringItem() { Text = new Text() { Text = String.Format("File: {0}", Path.GetFileName(projectFile.FileName)) } }); // ReSharper disable PossiblyMistakenUseOfParamsMethod fileNameRow.Append(new Cell() { CellReference = GetCell("C2", linesToAdd), StyleIndex = (UInt32Value) 3U, DataType = CellValues.SharedString, CellValue = new CellValue((AdditionalSharedStrings.Count + SharedStringsCount + FileNamesSharedStrings.Count).ToString(CultureInfo.InvariantCulture)) }); rows.Add(fileNameRow); // ReSharper restore PossiblyMistakenUseOfParamsMethod #endregion #region Rate Row rateRow1 = new Row() { RowIndex = (UInt32Value)(4U + linesToAdd), Spans = new ListValue<StringValue>() { InnerText = "3:9" }, DyDescent = 0.25D }; cells = new List<Cell>() { new Cell() {CellReference = GetCell("C4", linesToAdd), StyleIndex = (UInt32Value)1U, DataType = CellValues.SharedString, CellValue = new CellValue("16") }, new Cell() {CellReference = GetCell("D4", linesToAdd), StyleIndex = (UInt32Value) 1U, DataType = CellValues.Number, CellValue = new CellValue(projectFile.LineCharacters.ToString(CultureInfo.InvariantCulture))}, new Cell() {CellReference = GetCell("E4", linesToAdd), StyleIndex = (UInt32Value) 1U, DataType = CellValues.SharedString, CellValue = new CellValue("4")}, }; rateRow1.Append(cells.ConvertAll(c => (OpenXmlElement)c)); rows.Add(rateRow1); Row rateRow2 = new Row() { RowIndex = (UInt32Value)(5U + linesToAdd), Spans = new ListValue<StringValue>() { InnerText = "3:9" }, DyDescent = 0.25D }; cells = new List<Cell>() { new Cell() {CellReference = GetCell("C5", linesToAdd), StyleIndex = (UInt32Value)1U, DataType = CellValues.SharedString, CellValue = new CellValue("17") }, new Cell() {CellReference = GetCell("D5", linesToAdd), StyleIndex = (UInt32Value) 1U, DataType = CellValues.Number, CellValue = new CellValue(projectFile.RatePerLine.ToString(CultureInfo.InvariantCulture))}, new Cell() {CellReference = GetCell("E5", linesToAdd), StyleIndex = (UInt32Value) 1U, DataType = CellValues.SharedString, CellValue = new CellValue("15")}, }; rateRow2.Append(cells.ConvertAll(c => (OpenXmlElement)c)); rows.Add(rateRow2); #endregion #region lines payment infos Row justLinesRow = new Row() { RowIndex = (UInt32Value)(7U + linesToAdd), Spans = new ListValue<StringValue>() { InnerText = "3:9" }, DyDescent = 0.25D }; justLinesRow.Append(new Cell() { CellReference = GetCell("C7", linesToAdd), StyleIndex = (UInt32Value)5U, DataType = CellValues.SharedString, CellValue = new CellValue("18") }); rows.Add(justLinesRow); Row charsRow = new Row() { RowIndex = (UInt32Value)(8U + linesToAdd), Spans = new ListValue<StringValue>() { InnerText = "3:9" }, DyDescent = 0.25D }; cells = new List<Cell>() { new Cell() {CellReference = GetCell("C8", linesToAdd), StyleIndex = (UInt32Value) 5U, DataType = CellValues.SharedString, CellValue = new CellValue("19")}, new Cell() {CellReference = GetCell("D8", linesToAdd), StyleIndex = (UInt32Value) 5U, DataType = CellValues.Number, CellValue = new CellValue(projectFile.LinesByCharacters.ToString(CultureInfo.InvariantCulture))}, new Cell() {CellReference = GetCell("F8", linesToAdd), StyleIndex = (UInt32Value) 5U, DataType = CellValues.SharedString, CellValue = new CellValue("20")}, new Cell() {CellReference = GetCell("G8", linesToAdd), StyleIndex = (UInt32Value) 5U, DataType = CellValues.Number, CellValue = new CellValue((projectFile.LinesByCharacters*projectFile.RatePerLine).ToString(CultureInfo.InvariantCulture))}, new Cell() {CellReference = GetCell("H8", linesToAdd), StyleIndex = (UInt32Value) 5U, DataType = CellValues.SharedString, CellValue = new CellValue("15")} }; charsRow.Append(cells.ConvertAll(c => (OpenXmlElement)c)); rows.Add(charsRow); Row keysRow = new Row() { RowIndex = (UInt32Value)(9U + linesToAdd), Spans = new ListValue<StringValue>() { InnerText = "3:9" }, DyDescent = 0.25D }; cells = new List<Cell>() { new Cell() {CellReference = GetCell("C9", linesToAdd), StyleIndex = (UInt32Value) 5U, DataType = CellValues.SharedString, CellValue = new CellValue("21")}, new Cell() {CellReference = GetCell("D9", linesToAdd), StyleIndex = (UInt32Value) 5U, DataType = CellValues.Number, CellValue = new CellValue(projectFile.LinesByKeyStrokes.ToString(CultureInfo.InvariantCulture))}, new Cell() {CellReference = GetCell("F9", linesToAdd), StyleIndex = (UInt32Value) 5U, DataType = CellValues.SharedString, CellValue = new CellValue("20")}, new Cell() {CellReference = GetCell("G9", linesToAdd), StyleIndex = (UInt32Value) 5U, DataType = CellValues.Number, CellValue = new CellValue((projectFile.LinesByKeyStrokes*projectFile.RatePerLine).ToString(CultureInfo.InvariantCulture))}, new Cell() {CellReference = GetCell("H9", linesToAdd), StyleIndex = (UInt32Value) 5U, DataType = CellValues.SharedString, CellValue = new CellValue("15")} }; keysRow.Append(cells.ConvertAll(c => (OpenXmlElement)c)); rows.Add(keysRow); #endregion #region header row Row headerRow = new Row() { RowIndex = (UInt32Value)(11U + linesToAdd), Spans = new ListValue<StringValue>() { InnerText = "3:9" }, DyDescent = 0.25D }; cells = new List<Cell>() { new Cell() {CellReference = GetCell("C11", linesToAdd), StyleIndex = (UInt32Value) 3U, DataType = CellValues.SharedString, CellValue = new CellValue("1")}, new Cell() {CellReference = GetCell("D11", linesToAdd), StyleIndex = (UInt32Value) 4U, DataType = CellValues.SharedString, CellValue = new CellValue("2")}, new Cell() {CellReference = GetCell("F11", linesToAdd), StyleIndex = (UInt32Value) 5U, DataType = CellValues.SharedString, CellValue = new CellValue("22")}, new Cell() {CellReference = GetCell("G11", linesToAdd), StyleIndex = (UInt32Value) 5U, DataType = CellValues.SharedString, CellValue = new CellValue("5")}, new Cell() {CellReference = GetCell("H11", linesToAdd), StyleIndex = (UInt32Value) 2U}, new Cell() {CellReference = GetCell("J11", linesToAdd), StyleIndex = (UInt32Value) 5U, DataType = CellValues.SharedString, CellValue = new CellValue("23")}, new Cell() {CellReference = GetCell("K11", linesToAdd), StyleIndex = (UInt32Value) 5U, DataType = CellValues.SharedString, CellValue = new CellValue("5")}, new Cell() {CellReference = GetCell("L11", linesToAdd), StyleIndex = (UInt32Value) 2U} }; headerRow.Append(cells.ConvertAll(c => (OpenXmlElement)c)); rows.Add(headerRow); #endregion #region value rows rows.Add(GenerateRowForProperty(12U, linesToAdd, projectFile, Templates.Templates.PerfectMatch)); rows.Add(GenerateRowForProperty(13U, linesToAdd, projectFile, Templates.Templates.ContextMatch)); rows.Add(GenerateRowForProperty(14U, linesToAdd, projectFile, Templates.Templates.Repetitions)); rows.Add(GenerateRowForProperty(15U, linesToAdd, projectFile, Templates.Templates.Percent100)); rows.Add(GenerateRowForProperty(16U, linesToAdd, projectFile, Templates.Templates.Percent95)); rows.Add(GenerateRowForProperty(17U, linesToAdd, projectFile, Templates.Templates.Percent85)); rows.Add(GenerateRowForProperty(18U, linesToAdd, projectFile, Templates.Templates.Percent75)); rows.Add(GenerateRowForProperty(19U, linesToAdd, projectFile, Templates.Templates.Percent50)); rows.Add(GenerateRowForProperty(20U, linesToAdd, projectFile, Templates.Templates.New)); rows.Add(GenerateRowForProperty(21U, linesToAdd, projectFile, Templates.Templates.Tags)); #endregion #region total rows Row emptyRow = new Row() { RowIndex = (UInt32Value)(22U + linesToAdd), Spans = new ListValue<StringValue>() { InnerText = "3:9" }, DyDescent = 0.25D }; cells = new List<Cell>() { new Cell() {CellReference = GetCell("F22", linesToAdd), StyleIndex = (UInt32Value) 12U}, new Cell() {CellReference = GetCell("G22", linesToAdd), StyleIndex = (UInt32Value) 12U}, new Cell() {CellReference = GetCell("H22", linesToAdd), StyleIndex = (UInt32Value) 12U}, new Cell() {CellReference = GetCell("J22", linesToAdd), StyleIndex = (UInt32Value) 12U}, new Cell() {CellReference = GetCell("K22", linesToAdd), StyleIndex = (UInt32Value) 12U}, new Cell() {CellReference = GetCell("L22", linesToAdd), StyleIndex = (UInt32Value) 12U}, }; emptyRow.Append(cells.ConvertAll(c => (OpenXmlElement)c)); rows.Add(emptyRow); Row totalRow = new Row() { RowIndex = (UInt32Value)(23U + linesToAdd), Spans = new ListValue<StringValue>() { InnerText = "3:9" }, DyDescent = 0.25D }; Decimal totalValueC = projectFile.ProjectProperties.Where(property => property.StandardType != StandardType.Global).Sum(property => property.ValueByLbC); Decimal totalValueK = projectFile.ProjectProperties.Where(property => property.StandardType != StandardType.Global).Sum(property => property.ValueByLbK); cells = new List<Cell>() { new Cell(){CellReference = GetCell("F23", linesToAdd),StyleIndex = (UInt32Value) 12U }, new Cell(){CellReference = GetCell("G23", linesToAdd),StyleIndex = (UInt32Value) 13U ,DataType = CellValues.Number, CellValue = new CellValue(totalValueC.ToString(CultureInfo.InvariantCulture))}, new Cell(){CellReference = GetCell("H23", linesToAdd), StyleIndex = (UInt32Value) 13U ,DataType = CellValues.SharedString, CellValue = new CellValue("15")}, new Cell(){CellReference = GetCell("J23", linesToAdd),StyleIndex = (UInt32Value) 12U }, new Cell(){CellReference = GetCell("K23", linesToAdd),StyleIndex = (UInt32Value) 13U ,DataType = CellValues.Number, CellValue = new CellValue(totalValueK.ToString(CultureInfo.InvariantCulture))}, new Cell(){CellReference = GetCell("L23", linesToAdd), StyleIndex = (UInt32Value) 13U ,DataType = CellValues.SharedString, CellValue = new CellValue("15")} }; totalRow.Append(cells.ConvertAll(c => (OpenXmlElement)c)); rows.Add(totalRow); #endregion sheetData.Append(rows.ConvertAll(c => (OpenXmlElement)c)); }
protected virtual void GenerateWorksheetDataContent(SheetData sheetData1, int linesToAdd, ProjectFile porjectFile) { }