public void PreferredWidthSettings() { //ExStart:PreferredWidthSettings Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert a table row made up of three cells which have different preferred widths. builder.StartTable(); // Insert an absolute sized cell. builder.InsertCell(); builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(40); builder.CellFormat.Shading.BackgroundPatternColor = Color.LightYellow; builder.Writeln("Cell at 40 points width"); // Insert a relative (percent) sized cell. builder.InsertCell(); builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20); builder.CellFormat.Shading.BackgroundPatternColor = Color.LightBlue; builder.Writeln("Cell at 20% width"); // Insert a auto sized cell. builder.InsertCell(); builder.CellFormat.PreferredWidth = PreferredWidth.Auto; builder.CellFormat.Shading.BackgroundPatternColor = Color.LightGreen; builder.Writeln( "Cell automatically sized. The size of this cell is calculated from the table preferred width."); builder.Writeln("In this case the cell will fill up the rest of the available space."); doc.Save(ArtifactsDir + "WorkingWithTables.PreferredWidthSettings.docx"); //ExEnd:PreferredWidthSettings }
/// <summary> /// Shows how to set the different preferred width settings. /// </summary> private static void SetPreferredWidthSettings(string dataDir) { // ExStart:SetPreferredWidthSettings Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert a table row made up of three cells which have different preferred widths. Table table = builder.StartTable(); // Insert an absolute sized cell. builder.InsertCell(); builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(40); builder.CellFormat.Shading.BackgroundPatternColor = Color.LightYellow; builder.Writeln("Cell at 40 points width"); // Insert a relative (percent) sized cell. builder.InsertCell(); builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20); builder.CellFormat.Shading.BackgroundPatternColor = Color.LightBlue; builder.Writeln("Cell at 20% width"); // Insert a auto sized cell. builder.InsertCell(); builder.CellFormat.PreferredWidth = PreferredWidth.Auto; builder.CellFormat.Shading.BackgroundPatternColor = Color.LightGreen; builder.Writeln("Cell automatically sized. The size of this cell is calculated from the table preferred width."); builder.Writeln("In this case the cell will fill up the rest of the available space."); dataDir = dataDir + "Table.CellPreferredWidths_out.doc"; // Save the document to disk. doc.Save(dataDir); // ExEnd:SetPreferredWidthSettings Console.WriteLine("\nDifferent preferred width settings set successfully.\nFile saved at " + dataDir); }
// Token: 0x06000010 RID: 16 RVA: 0x00002640 File Offset: 0x00000840 public bool InsertScoreTable(bool dishand, bool distab, string handText) { bool result; try { this.oWordApplic.StartTable(); this.oWordApplic.ParagraphFormat.Alignment = ParagraphAlignment.Left; this.oWordApplic.InsertCell(); this.oWordApplic.CellFormat.Width = 100.0; this.oWordApplic.CellFormat.PreferredWidth = PreferredWidth.FromPoints(115.0); this.oWordApplic.CellFormat.Borders.LineStyle = LineStyle.None; this.oWordApplic.StartTable(); this.oWordApplic.RowFormat.Height = 20.2; this.oWordApplic.InsertCell(); this.oWordApplic.CellFormat.Borders.LineStyle = LineStyle.Single; this.oWordApplic.Font.Size = 10.5; this.oWordApplic.Bold = false; this.oWordApplic.Write("评卷人"); this.oWordApplic.CellFormat.VerticalAlignment = CellVerticalAlignment.Center; this.oWordApplic.ParagraphFormat.Alignment = ParagraphAlignment.Center; this.oWordApplic.CellFormat.Width = 50.0; this.oWordApplic.CellFormat.PreferredWidth = PreferredWidth.FromPoints(50.0); this.oWordApplic.RowFormat.Height = 20.0; this.oWordApplic.InsertCell(); this.oWordApplic.CellFormat.Borders.LineStyle = LineStyle.Single; this.oWordApplic.Font.Size = 10.5; this.oWordApplic.Bold = false; this.oWordApplic.Write("得分"); this.oWordApplic.CellFormat.VerticalAlignment = CellVerticalAlignment.Center; this.oWordApplic.ParagraphFormat.Alignment = ParagraphAlignment.Center; this.oWordApplic.CellFormat.Width = 50.0; this.oWordApplic.CellFormat.PreferredWidth = PreferredWidth.FromPoints(50.0); this.oWordApplic.EndRow(); this.oWordApplic.RowFormat.Height = 25.0; this.oWordApplic.InsertCell(); this.oWordApplic.RowFormat.Height = 25.0; this.oWordApplic.InsertCell(); this.oWordApplic.EndRow(); this.oWordApplic.EndTable(); this.oWordApplic.InsertCell(); this.oWordApplic.CellFormat.Width = 390.0; this.oWordApplic.CellFormat.PreferredWidth = PreferredWidth.Auto; this.oWordApplic.CellFormat.Borders.LineStyle = LineStyle.None; this.oWordApplic.CellFormat.VerticalAlignment = CellVerticalAlignment.Center; this.oWordApplic.ParagraphFormat.Alignment = ParagraphAlignment.Left; this.oWordApplic.Font.Size = 11.0; this.oWordApplic.Bold = true; this.oWordApplic.Write(handText); this.oWordApplic.EndRow(); this.oWordApplic.RowFormat.Height = 28.0; this.oWordApplic.EndTable(); result = true; } catch { result = false; } return(result); }
public void NegativeIndent() { //ExStart //ExFor:HtmlSaveOptions.AllowNegativeIndent //ExFor:HtmlSaveOptions.TableWidthOutputMode //ExSummary:Shows how to preserve negative indents in the output .html. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert a table and give it a negative value for its indent, effectively pushing it out of the left page boundary Table table = builder.StartTable(); builder.InsertCell(); builder.Write("Cell 1"); builder.InsertCell(); builder.Write("Cell 2"); builder.EndTable(); table.LeftIndent = -36; table.PreferredWidth = PreferredWidth.FromPoints(144); // When saving to .html, this indent will only be preserved if we set this flag HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.Html); options.AllowNegativeIndent = true; options.TableWidthOutputMode = HtmlElementSizeOutputMode.RelativeOnly; // The first cell with "Cell 1" will not be visible in the output doc.Save(ArtifactsDir + "HtmlSaveOptions.AllowNegativeIndent.html", options); //ExEnd }
// Token: 0x06000011 RID: 17 RVA: 0x000029F0 File Offset: 0x00000BF0 public bool InsertTable(DataTable dt, bool haveBorder) { Table table = this.oWordApplic.StartTable(); ParagraphAlignment alignment = this.oWordApplic.ParagraphFormat.Alignment; this.oWordApplic.ParagraphFormat.Alignment = ParagraphAlignment.Center; for (int i = 0; i < dt.Rows.Count; i++) { this.oWordApplic.RowFormat.Height = 25.0; for (int j = 0; j < dt.Columns.Count; j++) { this.oWordApplic.InsertCell(); this.oWordApplic.Font.Size = 10.5; this.oWordApplic.Font.Name = "宋体"; this.oWordApplic.CellFormat.VerticalAlignment = CellVerticalAlignment.Center; this.oWordApplic.ParagraphFormat.Alignment = ParagraphAlignment.Center; this.oWordApplic.CellFormat.Width = 60.0; this.oWordApplic.CellFormat.PreferredWidth = PreferredWidth.FromPoints(50.0); if (haveBorder) { this.oWordApplic.CellFormat.Borders.LineStyle = LineStyle.Single; } this.oWordApplic.Write(dt.Rows[i][j].ToString()); } this.oWordApplic.EndRow(); } this.oWordApplic.EndTable(); this.oWordApplic.ParagraphFormat.Alignment = alignment; table.Alignment = TableAlignment.Center; table.PreferredWidth = PreferredWidth.Auto; table.SetBorder(BorderType.Left, LineStyle.Single, 2.0, Color.Black, true); table.SetBorder(BorderType.Right, LineStyle.Single, 2.0, Color.Black, true); table.SetBorder(BorderType.Top, LineStyle.Single, 2.0, Color.Black, true); table.SetBorder(BorderType.Bottom, LineStyle.Single, 2.0, Color.Black, true); return(true); }
public static Table WriteTable(Aspose.Words.DocumentBuilder builder, DataTable dt, int startRow, IList <double> colwidth) { var tableW = ConfigurationManager.AppSettings["tableWidth"].ToInt(); builder.ParagraphFormat.StyleIdentifier = Aspose.Words.StyleIdentifier.BodyText; var table = builder.StartTable(); //table.LeftIndent = 20.0; //table.AllowAutoFit = false; builder.RowFormat.Height = 25.0; builder.CellFormat.FitText = false; var lstW = new List <double>(); var ww = colwidth.Sum(); foreach (var v in colwidth) { lstW.Add((tableW * v / ww).Round()); } builder.RowFormat.HeightRule = HeightRule.Auto;// HeightRule.AtLeast builder.CellFormat.Shading.BackgroundPatternColor = Color.FromArgb(191, 191, 191); builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center; builder.ParagraphFormat.Alignment = ParagraphAlignment.Center; builder.Font.Size = 11; builder.Font.Name = "宋体"; for (int i = 0; i < dt.Columns.Count; i++) { builder.InsertCell(); builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(lstW[i]); builder.Write(dt.Columns[i].ColumnName); } builder.EndRow(); builder.Font.Size = 10.5; builder.CellFormat.Shading.BackgroundPatternColor = Color.White; builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center; builder.ParagraphFormat.Alignment = ParagraphAlignment.Center; for (int j = startRow; j < dt.Rows.Count; j++) { for (int i = 0; i < dt.Columns.Count; i++) { builder.InsertCell(); //builder.CellFormat.Width = lstW[i]; builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(lstW[i]); //builder.CellFormat.WrapText = true ; // builder.CellFormat.FitText = false; builder.Write(dt.Rows[j][i].ToString().Trim()); } builder.EndRow(); } builder.EndTable(); table.AllowAutoFit = false; //table.AutoFit(AutoFitBehavior.FixedColumnWidths); //MergeCell(builder, table, mcell); return(table); }
private void PintaTabla(DocumentBuilder docBuilder, DocumentoInstanciaXbrlDto instancia, IndiceReporteDTO rolAExportar, ReporteXBRLDTO estructuraReporte, IList <ConceptoReporteDTO> listaConseptosReporte) { docBuilder.Writeln(); Table tablaActual = docBuilder.StartTable(); Color colorTitulo = Color.FromArgb(ColorTituloTabla[0], ColorTituloTabla[1], ColorTituloTabla[2]); docBuilder.ParagraphFormat.SpaceAfter = 0; docBuilder.ParagraphFormat.SpaceBefore = 2; ConceptoReporteDTO primerConcepto = null; if (!estructuraReporte.Roles.ContainsKey(rolAExportar.Rol)) { throw new IndexOutOfRangeException("No existe el rol [" + rolAExportar.Rol + "] dentro del listado de roles del reporte."); } if (estructuraReporte.Roles.ContainsKey(rolAExportar.Rol)) { foreach (ConceptoReporteDTO concepto in estructuraReporte.Roles[rolAExportar.Rol]) { if (!concepto.Abstracto) { primerConcepto = concepto; break; } } } establecerFuenteTituloCampo(docBuilder); docBuilder.Font.Size = TamanioLetraTituloTabla; docBuilder.InsertCell(); //tablaActual.StyleIdentifier = StyleIdentifier.LIGHT_GRID_ACCENT_1; //tablaActual.StyleOptions = TableStyleOptions.FIRST_ROW; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; docBuilder.Font.Color = Color.White; docBuilder.Write(estructuraReporte.ObtenValorEtiquetaReporte("ETIQUETA_CONCEPTO")); foreach (String periodo in primerConcepto.Hechos.Keys) { docBuilder.InsertCell(); docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center; docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); //docBuilder.CellFormat.Width = 35; docBuilder.CellFormat.WrapText = false; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; String descPeriodo = estructuraReporte.PeriodosReporte[periodo]; docBuilder.Writeln(estructuraReporte.Titulos[periodo]); docBuilder.Write(descPeriodo.Replace("_", " - ")); } docBuilder.RowFormat.HeadingFormat = true; docBuilder.EndRow(); establecerFuenteValorCampo(docBuilder); docBuilder.Font.Size = TamanioLetraContenidoTabla; foreach (ConceptoReporteDTO concepto in listaConseptosReporte) { // string valor = ObtenertipoDato(concepto, TIPO_DATO_MONETARY); //string tipoNoNegativo = ObtenertipoDato(concepto, TIPO_DATO_NoNEGATIVO); if (concepto.IdConcepto != ID_Importe && concepto.IdConcepto != ID_IVA && concepto.IdConcepto != ID_Total) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; docBuilder.CellFormat.Shading.BackgroundPatternColor = Color.White; docBuilder.CellFormat.WrapText = true; docBuilder.Font.Color = Color.Black; if (concepto.Abstracto) { docBuilder.Bold = true; docBuilder.Font.Color = Color.White; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; } else { docBuilder.Bold = false; } docBuilder.ParagraphFormat.LeftIndent = (concepto.Tabuladores < 0 ? concepto.Tabuladores : 0); docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left; if (concepto.AtributosAdicionales != null) { if (concepto.AtributosAdicionales.Count == 1) { conceptosEnIndice(docBuilder, concepto); } else { docBuilder.Write(concepto.Valor); } } else { docBuilder.Write(concepto.Valor); } if (concepto.Abstracto) { for (int iCell = 0; iCell < primerConcepto.Hechos.Count(); iCell++) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); } } else { foreach (HechoReporteDTO hecho in concepto.Hechos.Values) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); docBuilder.ParagraphFormat.LeftIndent = 0; if (concepto.Numerico) { docBuilder.CellFormat.WrapText = true; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Right; } else { docBuilder.CellFormat.WrapText = false; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left; } escribirValorHecho(docBuilder, estructuraReporte, hecho, concepto); } } docBuilder.RowFormat.AllowBreakAcrossPages = true; docBuilder.RowFormat.HeadingFormat = false; docBuilder.EndRow(); } } establecerBordesGrisesTabla(tablaActual); docBuilder.EndTable(); docBuilder.Writeln(); }
/// /// (non-Javadoc) /// @see com.bmv.spread.xbrl.reportes.exportador.ExportadorRolDocumentoInstancia#exportarRolAWord(com.aspose.words.DocumentBuilder, com.hh.xbrl.abax.viewer.application.dto.DocumentoInstanciaXbrlDto, com.bmv.spread.xbrl.reportes.dto.IndiceReporteDTO, com.bmv.spread.xbrl.reportes.dto.ReporteXBRLDTO) //// override public void exportarRolAWord(DocumentBuilder docBuilder, DocumentoInstanciaXbrlDto instancia, IndiceReporteDTO rolAExportar, ReporteXBRLDTO estructuraReporte) { Color colorTitulo = Color.FromArgb(ColorTituloTabla[0], ColorTituloTabla[1], ColorTituloTabla[2]); docBuilder.CurrentSection.PageSetup.Orientation = Orientation.Portrait; docBuilder.CurrentSection.PageSetup.LeftMargin = 40; docBuilder.CurrentSection.PageSetup.RightMargin = 40; escribirEncabezado(docBuilder, instancia, estructuraReporte, true); imprimirTituloRol(docBuilder, rolAExportar); //Escribir nota inicial IList <ConceptoReporteDTO> conceptos = estructuraReporte.Roles[rolAExportar.Rol]; HechoReporteDTO hechoNota = null; var conceptoNota = "ifrs_mx-cor_20141205_InformacionARevelarSobrePosicionMonetariaEnMonedaExtranjeraBloqueDeTexto"; foreach (var concepto in conceptos) { if (!concepto.IdConcepto.Equals(conceptoNota)) { continue; } foreach (var llave in concepto.Hechos.Keys) { hechoNota = concepto.Hechos[llave]; if (hechoNota != null) { if (String.IsNullOrWhiteSpace(hechoNota.Valor) && instancia.HechosPorIdConcepto.ContainsKey(conceptoNota)) { var idsHechos = instancia.HechosPorIdConcepto[conceptoNota]; foreach (var idHecho in idsHechos) { if (instancia.HechosPorId.ContainsKey(idHecho)) { var hechoReal = instancia.HechosPorId[idHecho]; if (!String.IsNullOrWhiteSpace(hechoReal.Valor)) { hechoNota.Valor = hechoReal.Valor; break; } } } } if (!String.IsNullOrWhiteSpace(hechoNota.Valor)) { escribirConceptoEnTablaNota(docBuilder, estructuraReporte, hechoNota, concepto); break; } } } } //conceptos.Remove(0); conceptos = ((List <ConceptoReporteDTO>)conceptos).GetRange(1, conceptos.Count() - 1); Table tablaActual = docBuilder.StartTable(); ConceptoReporteDTO primerConcepto = null; foreach (ConceptoReporteDTO concepto in conceptos) { //estructuraReporte.Roles[rolAExportar.Rol]){ if (!concepto.Abstracto) { primerConcepto = concepto; break; } } docBuilder.Font.Color = Color.White; docBuilder.ParagraphFormat.SpaceAfter = 0; docBuilder.ParagraphFormat.SpaceBefore = 2; establecerFuenteTituloCampo(docBuilder); docBuilder.Font.Size = TamanioLetraTituloTabla; //Titlo de dimension docBuilder.InsertCell(); docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; docBuilder.CellFormat.HorizontalMerge = CellMerge.None; int iCol = 0; foreach (String columna in primerConcepto.Hechos.Keys) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); docBuilder.CellFormat.WrapText = false; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; if (iCol == 0) { String descPeriodo = (String)estructuraReporte.ParametrosReporte["ifrs_mx-cor_20141205_MonedasEje_HEADER"]; docBuilder.Write(descPeriodo); docBuilder.CellFormat.HorizontalMerge = CellMerge.First; } else { docBuilder.CellFormat.HorizontalMerge = CellMerge.Previous; } iCol++; } docBuilder.EndRow(); docBuilder.InsertCell(); docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; docBuilder.CellFormat.HorizontalMerge = CellMerge.None; foreach (String columna in primerConcepto.Hechos.Keys) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); docBuilder.CellFormat.WrapText = false; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; String descPeriodo = (String)estructuraReporte.ParametrosReporte[columna + "_HEADER"]; docBuilder.Write(descPeriodo); docBuilder.CellFormat.HorizontalMerge = CellMerge.First; } docBuilder.EndRow(); establecerFuenteValorCampo(docBuilder); docBuilder.Font.Size = TamanioLetraContenidoTabla; foreach (ConceptoReporteDTO concepto in conceptos) { if (concepto.Abstracto && !ConceptosAbstractosPermitidos.Contains(concepto.IdConcepto)) { continue; } docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; docBuilder.CellFormat.Shading.BackgroundPatternColor = Color.White; docBuilder.CellFormat.WrapText = true; docBuilder.Font.Color = Color.Black; if (concepto.Abstracto) { docBuilder.Bold = true; docBuilder.Font.Color = Color.White; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; } else { docBuilder.Bold = false; } docBuilder.ParagraphFormat.LeftIndent = (concepto.Tabuladores < 0 ? concepto.Tabuladores : 0); docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left; docBuilder.Write(concepto.Valor); if (concepto.Abstracto) { for (int iCell = 0; iCell < primerConcepto.Hechos.Count(); iCell++) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); } } else { foreach (HechoReporteDTO hecho in concepto.Hechos.Values) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); docBuilder.ParagraphFormat.LeftIndent = 0; if (concepto.Numerico) { docBuilder.CellFormat.WrapText = true; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Right; } else { docBuilder.CellFormat.WrapText = false; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left; } escribirValorHecho(docBuilder, estructuraReporte, hecho, concepto); } } docBuilder.RowFormat.AllowBreakAcrossPages = true; docBuilder.RowFormat.HeadingFormat = false; docBuilder.EndRow(); } tablaActual.SetBorders(LineStyle.Single, 1, ReportConstants.DEFAULT_BORDER_GREY_COLOR); docBuilder.EndTable(); }
private void PintaTabla(DocumentBuilder docBuilder, DocumentoInstanciaXbrlDto instancia, IndiceReporteDTO rolAExportar, ReporteXBRLDTO estructuraReporte, IList <ConceptoReporteDTO> listaConseptosReporte) { Table tablaActual = docBuilder.StartTable(); Color colorTitulo = Color.FromArgb(ColorTituloTabla[0], ColorTituloTabla[1], ColorTituloTabla[2]); docBuilder.ParagraphFormat.SpaceAfter = 0; docBuilder.ParagraphFormat.SpaceBefore = 2; ConceptoReporteDTO primerConcepto = null; if (!estructuraReporte.Roles.ContainsKey(rolAExportar.Rol)) { throw new IndexOutOfRangeException("No existe el rol [" + rolAExportar.Rol + "] dentro del listado de roles del reporte."); } if (estructuraReporte.Roles.ContainsKey(rolAExportar.Rol)) { foreach (ConceptoReporteDTO concepto in estructuraReporte.Roles[rolAExportar.Rol]) { if (!concepto.Abstracto) { primerConcepto = concepto; break; } } } establecerFuenteTituloCampo(docBuilder); docBuilder.Font.Size = TamanioLetraTituloTabla; docBuilder.InsertCell(); //tablaActual.StyleIdentifier = StyleIdentifier.LIGHT_GRID_ACCENT_1; //tablaActual.StyleOptions = TableStyleOptions.FIRST_ROW; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; docBuilder.Font.Color = Color.White; docBuilder.Write(estructuraReporte.ObtenValorEtiquetaReporte("ETIQUETA_CONCEPTO")); String fechaReporteCadena = estructuraReporte.FechaReporte; String fechaConstitucionCadena = estructuraReporte.Plantilla.ObtenerParametrosConfiguracion()["fechaConstitucion"]; DateTime fechaReporte = DateReporteUtil.obtenerFecha(fechaReporteCadena); DateTime fechaConstitucion = DateReporteUtil.obtenerFecha(fechaConstitucionCadena); int diferenciaAnios = fechaReporte.Year - fechaConstitucion.Year; var periodosPermitidos = new Dictionary <String, bool>() { { "anual_actual", true }, }; if (diferenciaAnios == 1) { periodosPermitidos.Add("anual_anterior", true); } else if (diferenciaAnios >= 2) { periodosPermitidos.Add("anual_anterior", true); periodosPermitidos.Add("anual_pre_anterior", true); } foreach (String periodo in primerConcepto.Hechos.Keys) { if (!periodosPermitidos.ContainsKey(periodo)) { continue; } docBuilder.InsertCell(); docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center; docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); //docBuilder.CellFormat.Width = 35; docBuilder.CellFormat.WrapText = false; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; String descPeriodo = estructuraReporte.PeriodosReporte[periodo]; docBuilder.Writeln(estructuraReporte.Titulos[periodo]); docBuilder.Writeln(estructuraReporte.Moneda); docBuilder.Write(descPeriodo.Replace("_", " - ")); } docBuilder.RowFormat.HeadingFormat = true; docBuilder.EndRow(); establecerFuenteValorCampo(docBuilder); docBuilder.Font.Size = TamanioLetraContenidoTabla; foreach (ConceptoReporteDTO concepto in listaConseptosReporte) { /* if (ConceptosOcultar.Contains(concepto.IdConcepto)) * { * continue; * }*/ //if(!concepto.Abstracto && !concepto.Numerico) //{ // establecerBordesGrisesTabla(tablaActual); // docBuilder.EndTable(); // var subLista = ObtenSubLista(listaConseptosReporte, listaConseptosReporte.IndexOf(concepto)); // EscribeNotas(docBuilder, instancia, rolAExportar, estructuraReporte, subLista); // return; //} if (concepto.TipoDato.EndsWith(TIPO_DATO_MONETARY) || concepto.TipoDato.EndsWith(TIPO_DATO_PERSHERE)) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; docBuilder.CellFormat.Shading.BackgroundPatternColor = Color.White; docBuilder.CellFormat.WrapText = true; docBuilder.Font.Color = Color.Black; if (concepto.Abstracto) { docBuilder.Bold = true; docBuilder.Font.Color = Color.White; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; } else { docBuilder.Bold = false; } docBuilder.ParagraphFormat.LeftIndent = (concepto.Tabuladores < 0 ? concepto.Tabuladores : 0); docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left; if (concepto.AtributosAdicionales != null) { if (concepto.AtributosAdicionales.Count == 1) { conceptosEnIndice(docBuilder, concepto); } else { docBuilder.Write(concepto.Valor); } } else { docBuilder.Write(concepto.Valor); } if (concepto.Abstracto) { for (int iCell = 0; iCell < primerConcepto.Hechos.Count(); iCell++) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); } } else { foreach (var periodo in concepto.Hechos.Keys) { if (!periodosPermitidos.ContainsKey(periodo)) { continue; } HechoReporteDTO hecho = concepto.Hechos[periodo]; if ((hecho != null && !String.IsNullOrWhiteSpace(hecho.Valor))) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); docBuilder.ParagraphFormat.LeftIndent = 0; if (concepto.Numerico) { docBuilder.CellFormat.WrapText = true; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Right; } else { docBuilder.CellFormat.WrapText = false; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left; } escribirValorHecho(docBuilder, estructuraReporte, hecho, concepto); } } docBuilder.RowFormat.AllowBreakAcrossPages = true; docBuilder.RowFormat.HeadingFormat = false; docBuilder.EndRow(); } } } establecerBordesGrisesTabla(tablaActual); docBuilder.EndTable(); }
public MemoryStream RenderCoverLetter(string addressBlock, string salutation, List <Screening> screenings) { Aspose.Words.Document wordDocument = new Aspose.Words.Document(new MemoryStream(SharedFilesConfiguration.Current.CoverLetter)); Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(wordDocument); //string address = string.Format("{0} {1}", state.WOTCCoordinator.FirstName == null ? string.Empty : state.WOTCCoordinator.FirstName.Trim(), state.WOTCCoordinator.LastName == null ? string.Empty : state.WOTCCoordinator.LastName.Trim()); //if (!string.IsNullOrEmpty(state.WOTCCoordinator.Title)) // address += "\n" + state.WOTCCoordinator.Title.Trim(); //if (!string.IsNullOrEmpty(state.WOTCCoordinator.Department)) // address += "\n" + state.WOTCCoordinator.Department.Trim(); //if (!string.IsNullOrEmpty(state.WOTCCoordinator.Division)) // address += "\n" + state.WOTCCoordinator.Division.Trim(); //address += string.Format("\n{0}, {1} {2}", state.WOTCCoordinator.City.Trim(), state.WOTCCoordinator.State.Trim(), state.WOTCCoordinator.ZipCode.Trim()); builder.MoveToBookmark("WOTCAddress"); builder.Writeln(addressBlock); builder.MoveToBookmark("Salutation"); builder.Writeln(salutation); builder.MoveToBookmark("EnclosureTable"); var table = builder.StartTable(); builder.InsertCell(); builder.RowFormat.Height = 15; builder.RowFormat.HeightRule = Aspose.Words.HeightRule.Exactly; builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(35); builder.Writeln("DOC"); builder.InsertCell(); builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(175); builder.Writeln("NAME"); builder.InsertCell(); builder.Writeln("SSN"); builder.InsertCell(); builder.Writeln("HIRE DATE"); builder.EndRow(); foreach (var screening in screenings.OrderBy(s => s.Applicant.LastName + "_" + s.Applicant.FirstName)) { builder.InsertCell(); builder.RowFormat.Height = 15; builder.RowFormat.HeightRule = Aspose.Words.HeightRule.Exactly; builder.Writeln("8850"); builder.InsertCell(); builder.RowFormat.Height = 15; builder.RowFormat.HeightRule = Aspose.Words.HeightRule.Exactly; builder.Writeln("9061"); builder.InsertCell(); builder.Writeln(string.Format("{0} {1}", screening.Applicant.FirstName.Trim(), screening.Applicant.LastName.Trim())); var social = string.IsNullOrEmpty(screening.Applicant.SocialSecurityNumber) ? "000-00-0000" : (screening.Applicant.SocialSecurityNumber.Length == 7 ? "0" + screening.Applicant.SocialSecurityNumber.Substring(0, 2) + "-" + screening.Applicant.SocialSecurityNumber.Substring(2, 2) + "-" + screening.Applicant.SocialSecurityNumber.Substring(4, 4) : screening.Applicant.SocialSecurityNumber.Substring(0, 3) + "-" + screening.Applicant.SocialSecurityNumber.Substring(3, 2) + "-" + screening.Applicant.SocialSecurityNumber.Substring(5, 4)); builder.InsertCell(); builder.Writeln(social); builder.InsertCell(); builder.Writeln(screening.WasHired.Value.ToString("MM/dd/yyyy")); builder.EndRow(); } builder.EndTable(); for (int i = 0; i < table.Rows.Count; i++) { table.Rows[i].RowFormat.Borders.LineStyle = Aspose.Words.LineStyle.None; } MemoryStream stream = new MemoryStream(); wordDocument.Save(stream, Aspose.Words.SaveFormat.Pdf); stream.Position = 0; return(stream); }
/// /// (non-Javadoc) /// @see com.bmv.spread.xbrl.reportes.exportador.ExportadorRolDocumentoInstancia#exportarRolAWord(com.aspose.words.DocumentBuilder, com.hh.xbrl.abax.viewer.application.dto.DocumentoInstanciaXbrlDto, com.bmv.spread.xbrl.reportes.dto.IndiceReporteDTO, com.bmv.spread.xbrl.reportes.dto.ReporteXBRLDTO) //// override public void exportarRolAWord(DocumentBuilder docBuilder, DocumentoInstanciaXbrlDto instancia, IndiceReporteDTO rolAExportar, ReporteXBRLDTO estructuraReporte) { docBuilder.CurrentSection.PageSetup.Orientation = Orientation.Portrait; docBuilder.CurrentSection.PageSetup.PaperSize = PaperSize.Letter; Color colorTitulo = Color.FromArgb(ColorTituloTabla[0], ColorTituloTabla[1], ColorTituloTabla[2]); docBuilder.CurrentSection.PageSetup.LeftMargin = 40; docBuilder.CurrentSection.PageSetup.RightMargin = 40; escribirEncabezado(docBuilder, instancia, estructuraReporte, true); imprimirTituloRol(docBuilder, rolAExportar); Table tablaActual = docBuilder.StartTable(); //docBuilder.ParagraphFormat.LineSpacing = 1.5; docBuilder.ParagraphFormat.SpaceAfter = 0; docBuilder.ParagraphFormat.SpaceBefore = 2; ConceptoReporteDTO primerConcepto = null; if (!estructuraReporte.Roles.ContainsKey(rolAExportar.Rol)) { throw new IndexOutOfRangeException("No existe el rol [" + rolAExportar.Rol + "] dentro del listado de roles del reporte."); } if (estructuraReporte.Roles.ContainsKey(rolAExportar.Rol)) { foreach (ConceptoReporteDTO concepto in estructuraReporte.Roles[rolAExportar.Rol]) { if (!concepto.Abstracto) { primerConcepto = concepto; break; } } } if (primerConcepto == null) { LogUtil.Error("No existen conceptos configurados para el rol: " + rolAExportar.Rol); throw new IndexOutOfRangeException("No existen conceptos configurados para el rol: " + rolAExportar.Rol); } establecerFuenteTituloCampo(docBuilder); docBuilder.Font.Size = TamanioLetraTituloTabla; docBuilder.InsertCell(); //tablaActual.StyleIdentifier = StyleIdentifier.LIGHT_GRID_ACCENT_1; //tablaActual.StyleOptions = TableStyleOptions.FIRST_ROW; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; docBuilder.Font.Color = Color.White; docBuilder.Write(estructuraReporte.ObtenValorEtiquetaReporte("ETIQUETA_CONCEPTO")); foreach (String periodo in primerConcepto.Hechos.Keys) { docBuilder.InsertCell(); docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center; docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); //docBuilder.CellFormat.Width = 35; docBuilder.CellFormat.WrapText = false; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; String descPeriodo = String.Empty; if (estructuraReporte.PeriodosReporte.ContainsKey(periodo)) { descPeriodo = estructuraReporte.PeriodosReporte[periodo]; } else if (estructuraReporte.ParametrosReporte.ContainsKey(periodo + "_HEADER")) { descPeriodo = (string)estructuraReporte.ParametrosReporte[(periodo + "_HEADER")]; } if (estructuraReporte.Titulos.ContainsKey(periodo)) { docBuilder.Writeln(estructuraReporte.Titulos[periodo]); } docBuilder.Write(descPeriodo.Replace("_", " - ")); } docBuilder.RowFormat.HeadingFormat = true; docBuilder.EndRow(); establecerFuenteValorCampo(docBuilder); docBuilder.Font.Size = TamanioLetraContenidoTabla; foreach (ConceptoReporteDTO concepto in estructuraReporte.Roles[rolAExportar.Rol]) { var conceptoNota = concepto.TipoDato.Contains("textBlockItemType"); docBuilder.InsertCell(); docBuilder.CellFormat.HorizontalMerge = CellMerge.None; docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; docBuilder.CellFormat.Shading.BackgroundPatternColor = Color.White; docBuilder.CellFormat.WrapText = true; docBuilder.Font.Color = Color.Black; if (concepto.Abstracto) { docBuilder.Bold = true; docBuilder.Font.Color = Color.White; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; } else { docBuilder.Bold = false; } docBuilder.ParagraphFormat.LeftIndent = (concepto.Tabuladores != null ? concepto.Tabuladores : 0); ///3); docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left; docBuilder.Write(concepto.Valor); if (concepto.Abstracto) { for (int iCell = 0; iCell < primerConcepto.Hechos.Count(); iCell++) { docBuilder.InsertCell(); docBuilder.CellFormat.HorizontalMerge = CellMerge.None; docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); } } else { if (conceptoNota) { //Extender el título HechoReporteDTO ultimoHecho = null; docBuilder.CellFormat.HorizontalMerge = CellMerge.First; foreach (HechoReporteDTO hecho in concepto.Hechos.Values) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); docBuilder.CellFormat.HorizontalMerge = CellMerge.Previous; ultimoHecho = hecho; } docBuilder.RowFormat.AllowBreakAcrossPages = true; docBuilder.RowFormat.HeadingFormat = false; docBuilder.EndRow(); docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; docBuilder.CellFormat.Shading.BackgroundPatternColor = Color.White; docBuilder.CellFormat.WrapText = true; docBuilder.Font.Color = Color.Black; docBuilder.CellFormat.WrapText = false; escribirValorHecho(docBuilder, estructuraReporte, ultimoHecho, concepto); docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left; docBuilder.CellFormat.HorizontalMerge = CellMerge.First; foreach (HechoReporteDTO hecho in concepto.Hechos.Values) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); docBuilder.ParagraphFormat.LeftIndent = 0; docBuilder.CellFormat.HorizontalMerge = CellMerge.Previous; } } else { foreach (HechoReporteDTO hecho in concepto.Hechos.Values) { docBuilder.InsertCell(); docBuilder.CellFormat.HorizontalMerge = CellMerge.None; docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); docBuilder.ParagraphFormat.LeftIndent = 0; if (concepto.Numerico) { docBuilder.CellFormat.WrapText = true; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Right; } else { docBuilder.CellFormat.WrapText = false; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left; } escribirValorHecho(docBuilder, estructuraReporte, hecho, concepto); } } } docBuilder.RowFormat.AllowBreakAcrossPages = true; docBuilder.RowFormat.HeadingFormat = false; docBuilder.EndRow(); } establecerBordesGrisesTabla(tablaActual); docBuilder.EndTable(); }
private void escribirTablaIntervaloTiempo(DocumentBuilder docBuilder, ReporteXBRLDTO estructuraReporte, DocumentoInstanciaXbrlDto instancia, List <String> IdsConceptos, int inicio, int final) { Color colorTitulo = Color.FromArgb(ColorTituloTabla[0], ColorTituloTabla[1], ColorTituloTabla[2]); IList <string> ConceptosAbstractosPermitidos = new List <string>() { IdsConceptos[inicio] }; List <ConceptoReporteDTO> conceptos = new List <ConceptoReporteDTO>(); if (inicio < final & final <= IdsConceptos.Count) { for (int i = inicio; i < final; i++) { conceptos.Add(BuscarPorIdConcepto(estructuraReporte, IdsConceptos[i])); } } docBuilder.Writeln(); Table tablaActual = docBuilder.StartTable(); ConceptoReporteDTO primerConcepto = null; foreach (ConceptoReporteDTO concepto in conceptos) { if (!concepto.Abstracto) { primerConcepto = concepto; break; } } docBuilder.Font.Color = Color.White; docBuilder.ParagraphFormat.SpaceAfter = 0; docBuilder.ParagraphFormat.SpaceBefore = 2; establecerFuenteTituloCampo(docBuilder); docBuilder.Font.Size = TamanioLetraTituloTabla; //Titlo de dimension docBuilder.InsertCell(); docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; docBuilder.CellFormat.HorizontalMerge = CellMerge.None; int iCol = 0; foreach (String columna in primerConcepto.Hechos.Keys) { if (!columna.Equals("periodo_actual")) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); docBuilder.CellFormat.WrapText = false; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; if (iCol == 0) { String descPeriodo = (String)estructuraReporte.ParametrosReporte["annext_TimeIntervalAxis_HEADER"]; docBuilder.Write(descPeriodo); docBuilder.CellFormat.HorizontalMerge = CellMerge.First; } else { docBuilder.CellFormat.HorizontalMerge = CellMerge.Previous; } iCol++; } } docBuilder.EndRow(); docBuilder.InsertCell(); docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; docBuilder.CellFormat.HorizontalMerge = CellMerge.None; foreach (String columna in primerConcepto.Hechos.Keys) { if (!columna.Equals("periodo_actual")) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); docBuilder.CellFormat.WrapText = false; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; String descPeriodo = (String)estructuraReporte.ParametrosReporte[columna + "_HEADER"]; docBuilder.Write(descPeriodo); docBuilder.CellFormat.HorizontalMerge = CellMerge.First; } } docBuilder.EndRow(); establecerFuenteValorCampo(docBuilder); docBuilder.Font.Size = TamanioLetraContenidoTabla; foreach (ConceptoReporteDTO concepto in conceptos) { if (concepto.Abstracto && !ConceptosAbstractosPermitidos.Contains(concepto.IdConcepto)) { continue; } docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; docBuilder.CellFormat.Shading.BackgroundPatternColor = Color.White; docBuilder.CellFormat.WrapText = true; docBuilder.Font.Color = Color.Black; if (concepto.Abstracto) { docBuilder.Bold = true; docBuilder.Font.Color = Color.White; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; } else { docBuilder.Bold = false; } docBuilder.ParagraphFormat.LeftIndent = (concepto.Tabuladores < 0 ? concepto.Tabuladores : 0); docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left; docBuilder.Write(concepto.Valor); if (concepto.Abstracto) { for (int iCell = 0; iCell < primerConcepto.Hechos.Count(); iCell++) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); } } else { foreach (String contexto in concepto.Hechos.Keys) { if (!contexto.Equals("periodo_actual")) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); docBuilder.ParagraphFormat.LeftIndent = 0; if (concepto.Numerico) { docBuilder.CellFormat.WrapText = true; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Right; } else { docBuilder.CellFormat.WrapText = false; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left; } escribirValorHecho(docBuilder, estructuraReporte, concepto.Hechos[contexto], concepto); } } } docBuilder.RowFormat.AllowBreakAcrossPages = true; docBuilder.RowFormat.HeadingFormat = false; docBuilder.EndRow(); } tablaActual.SetBorders(LineStyle.Single, 1, ReportConstants.DEFAULT_BORDER_GREY_COLOR); docBuilder.EndTable(); docBuilder.Writeln(); }
private void escribirTablaSerie(DocumentBuilder docBuilder, ReporteXBRLDTO estructuraReporte, DocumentoInstanciaXbrlDto instancia, HipercuboReporteDTO hipercubo) { docBuilder.Font.Size = TamanioLetraTituloTabla; docBuilder.Writeln(); Table tablaDesglose = docBuilder.StartTable(); docBuilder.CellFormat.Shading.BackgroundPatternColor = Color.FromArgb(ColorTituloTabla[0], ColorTituloTabla[1], ColorTituloTabla[2]); docBuilder.ParagraphFormat.SpaceAfter = 0; docBuilder.ParagraphFormat.SpaceBefore = 2; docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left; docBuilder.Font.Name = TipoLetraTituloConcepto; docBuilder.Font.Bold = TituloConceptoNegrita; docBuilder.Font.Size = TamanioLetraTituloTabla; docBuilder.Font.Color = Color.White; docBuilder.Write((String)estructuraReporte.ParametrosReporte["annext_SerieTypedAxis_HEADER"]); for (var indexTitulo = 0; indexTitulo < hipercubo.Titulos.Count; indexTitulo++) { docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaTitulos); var titulo = hipercubo.Titulos[indexTitulo]; docBuilder.InsertCell(); docBuilder.Write(titulo); } docBuilder.EndRow(); docBuilder.CellFormat.Shading.BackgroundPatternColor = Color.White; docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); docBuilder.Font.Size = TamanioLetraContenidoTabla; docBuilder.Font.Color = Color.Black; foreach (var idConcepto in hipercubo.Hechos.Keys) { var matrizPlantillaContexto = hipercubo.Hechos[idConcepto]; docBuilder.InsertCell(); var nombreConcepto = ReporteXBRLUtil.obtenerEtiquetaConcepto(estructuraReporte.Lenguaje, ReporteXBRLUtil.ETIQUETA_DEFAULT, idConcepto, instancia); docBuilder.Font.Name = TipoLetraTituloConcepto; docBuilder.Font.Bold = false; docBuilder.Font.Size = TamanioLetraContenidoTabla; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left; docBuilder.Write(nombreConcepto); foreach (var idPlantillaContexto in matrizPlantillaContexto.Keys) { var listaHechos = matrizPlantillaContexto[idPlantillaContexto]; for (var indexHecho = 0; indexHecho < listaHechos.Length; indexHecho++) { var hecho = listaHechos[indexHecho]; var valorHecho = ReporteXBRLUtil.formatoDecimal(hecho.ValorNumerico, ReporteXBRLUtil.FORMATO_CANTIDADES_MONETARIAS); docBuilder.InsertCell(); docBuilder.Font.Name = TipoLetraTextos; docBuilder.Font.Bold = false; docBuilder.Font.Size = TamanioLetraContenidoTabla; docBuilder.ParagraphFormat.LeftIndent = 0; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Right; docBuilder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center; docBuilder.Write(valorHecho); } } docBuilder.EndRow(); } docBuilder.EndTable(); docBuilder.Writeln(); }
override public void exportarRolAWord(DocumentBuilder docBuilder, DocumentoInstanciaXbrlDto instancia, IndiceReporteDTO rolAExportar, ReporteXBRLDTO estructuraReporte) { var colorTitulo = Color.FromArgb(ColorTituloTabla[0], ColorTituloTabla[1], ColorTituloTabla[2]); docBuilder.CurrentSection.PageSetup.Orientation = Orientation.Landscape; if (UsarHojaOficio) { docBuilder.CurrentSection.PageSetup.PaperSize = PaperSize.Legal; } else { docBuilder.CurrentSection.PageSetup.PaperSize = PaperSize.Letter; } escribirEncabezado(docBuilder, instancia, estructuraReporte, true); var etiquetaHoja = estructuraReporte.ObtenValorEtiquetaReporte("ETIQUETA_HOJA"); var etiquetaDe = estructuraReporte.ObtenValorEtiquetaReporte("ETIQUETA_DE"); imprimirTituloRol(docBuilder, rolAExportar); //var pageCount = docBuilder.Document.PageCount; Table tablaActual = docBuilder.StartTable(); ConceptoReporteDTO primerConcepto = null; foreach (ConceptoReporteDTO concepto in estructuraReporte.Roles[rolAExportar.Rol]) { if (!concepto.Abstracto) { primerConcepto = concepto; break; } } int iCol = 0; HechoReporteDTO hecho = null; List <String> columnas = new List <String>(); foreach (String periodoItera in primerConcepto.Hechos.Keys) { columnas.Add(periodoItera); } String periodo = null; int hoja = 1; int hojas = (int)Math.Ceiling((double)columnas.Count() / (double)ColumnasPorHoja); while (iCol < columnas.Count()) { int iColFinalInicio = iCol; int iColSeccionActual = iCol; //Fila encabezado docBuilder.ParagraphFormat.SpaceAfter = 0; docBuilder.ParagraphFormat.SpaceBefore = 2; establecerFuenteTituloCampo(docBuilder); docBuilder.Font.Size = TamanioLetraTituloTabla; docBuilder.InsertCell(); docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaTitulos); docBuilder.CellFormat.HorizontalMerge = CellMerge.None; docBuilder.InsertCell(); docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); docBuilder.CellFormat.HorizontalMerge = CellMerge.First; docBuilder.Font.Color = Color.White; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center; docBuilder.Write((String)estructuraReporte.ParametrosReporte["ifrs-full_ComponentsOfEquityAxis_HEADER"]); for (; iColSeccionActual + 1 < iColFinalInicio + ColumnasPorHoja && iColSeccionActual + 1 < columnas.Count(); iColSeccionActual++) { docBuilder.InsertCell(); docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); docBuilder.CellFormat.HorizontalMerge = CellMerge.Previous; } docBuilder.EndRow(); docBuilder.InsertCell(); docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaTitulos); docBuilder.CellFormat.HorizontalMerge = CellMerge.None; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center; docBuilder.Font.Color = Color.White; docBuilder.Font.Bold = true; if (hojas > 1) { docBuilder.Write(etiquetaHoja + " " + hoja + " " + etiquetaDe + " " + hojas); } iColSeccionActual = iCol; for (; iColSeccionActual < iColFinalInicio + ColumnasPorHoja && iColSeccionActual < columnas.Count(); iColSeccionActual++) { periodo = columnas[iColSeccionActual]; docBuilder.InsertCell(); docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center; docBuilder.CellFormat.HorizontalMerge = CellMerge.None; docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); docBuilder.CellFormat.WrapText = true; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; String descPeriodo = (String)estructuraReporte.ParametrosReporte[periodo + "_HEADER"]; docBuilder.Writeln(descPeriodo); iCol++; } docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; docBuilder.EndRow(); foreach (ConceptoReporteDTO concepto in estructuraReporte.Roles[rolAExportar.Rol]) { if (concepto.Abstracto && !ConceptosAbstractosPermitidos.Contains(concepto.IdConcepto)) { continue; } //LogUtil.Info("Exportador == > Concepto:[" + concepto.IdConcepto + "],\t\t\tAbstracto:[" + concepto.Abstracto + "],\t\thechos:[" + concepto.Hechos.Count() + "]"); iColSeccionActual = iColFinalInicio; docBuilder.InsertCell(); docBuilder.CellFormat.HorizontalMerge = CellMerge.None; if (hojas > 1) { docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaTitulos); } else { docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; } docBuilder.CellFormat.Shading.BackgroundPatternColor = Color.White; docBuilder.Font.Color = Color.Black; if (concepto.Abstracto) { docBuilder.Bold = true; docBuilder.Font.Color = Color.White; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; } else { docBuilder.Bold = false; } docBuilder.ParagraphFormat.LeftIndent = (concepto.Tabuladores != null?concepto.Tabuladores:0); ///3); docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left; docBuilder.Write(concepto.Valor); for (; iColSeccionActual < (iColFinalInicio + ColumnasPorHoja) && iColSeccionActual < columnas.Count(); iColSeccionActual++) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); docBuilder.ParagraphFormat.LeftIndent = 0; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Right; docBuilder.CellFormat.HorizontalMerge = CellMerge.None; if (concepto.Abstracto) { docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; } else { //LogUtil.Info("ExportadorEntro == > Concepto:[" + concepto.IdConcepto + "],\t\t\tSeccionActual:[" + columnas[iColSeccionActual] + "],\t\thecho:[" + hecho == null ? "sinHecho" : hecho.ValorFormateado ?? "null" + "]"); docBuilder.CellFormat.Shading.BackgroundPatternColor = Color.White; docBuilder.Font.Color = Color.Black; if (concepto.Hechos.ContainsKey(columnas[iColSeccionActual])) { hecho = concepto.Hechos[columnas[iColSeccionActual]]; } else { hecho = null; } if (hecho != null && hecho.ValorFormateado != null) { escribirLinkNotaAlPie(docBuilder, hecho, estructuraReporte); docBuilder.Write(hecho.ValorFormateado); } } } if (hojas > 1) { docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; } docBuilder.EndRow(); } if (iCol >= columnas.Count()) { break; } tablaActual.SetBorders(LineStyle.Single, 1, ReportConstants.DEFAULT_BORDER_GREY_COLOR); docBuilder.EndTable(); if (estructuraReporte.Roles[rolAExportar.Rol].Count < 25) { docBuilder.InsertBreak(BreakType.PageBreak); } /*if (pageCount == docBuilder.Document.PageCount) * { * docBuilder.InsertBreak(BreakType.PageBreak); * } * pageCount = docBuilder.Document.PageCount; */ tablaActual = docBuilder.StartTable(); hoja++; } tablaActual.SetBorders(LineStyle.Single, 1, ReportConstants.DEFAULT_BORDER_GREY_COLOR); docBuilder.EndTable(); }
public Form1() { InitializeComponent(); //2019/12/23 - 測試為何欄位的寬,無法調整 //造成確認表跑版 //PS:Aspose.Words.dll是2014版 //因為ischool指認識這個檔名 Document _doc = new Document(new MemoryStream(Properties.Resources.資料)); DocumentBuilder docBuilder = new DocumentBuilder(_doc); docBuilder.MoveToMergeField("資料"); Cell _cell = docBuilder.CurrentParagraph.ParentNode as Cell; #region Cell切割器 double MAXwidth = _cell.CellFormat.Width; double Cellwidth = MAXwidth / 3; CellFormat cf = _cell.CellFormat; cf.Width = Cellwidth; List <Cell> list = new List <Cell>(); list.Add(_cell); Row _row = _cell.ParentNode as Row; for (int xx = 0; xx < 3 - 1; xx++) { list.Add((_row.InsertAfter(new Cell(_cell.Document), _cell)) as Cell); } foreach (Cell each in list) { Console.WriteLine(each.CellFormat.Width); } foreach (Cell each in list) { each.CellFormat.PreferredWidth = PreferredWidth.FromPoints(Cellwidth); } #endregion SaveFileDialog sd = new System.Windows.Forms.SaveFileDialog(); sd.Title = "另存新檔"; sd.FileName = "資料(確認表).docx"; sd.Filter = "Word檔案 (*.Docx)|*.docx|所有檔案 (*.*)|*.*"; if (sd.ShowDialog() == DialogResult.OK) { try { _doc.Save(sd.FileName); System.Diagnostics.Process.Start(sd.FileName); } catch { MessageBox.Show("指定路徑無法存取。", "建立檔案失敗", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } } }
/// /// (non-Javadoc) /// @see com.bmv.spread.xbrl.reportes.exportador.ExportadorRolDocumentoInstancia#exportarRolAWord(com.aspose.words.DocumentBuilder, com.hh.xbrl.abax.viewer.application.dto.DocumentoInstanciaXbrlDto, com.bmv.spread.xbrl.reportes.dto.IndiceReporteDTO, com.bmv.spread.xbrl.reportes.dto.ReporteXBRLDTO) //// override public void exportarRolAWord(DocumentBuilder docBuilder, DocumentoInstanciaXbrlDto instancia, IndiceReporteDTO rolAExportar, ReporteXBRLDTO estructuraReporte) { escribirEncabezado(docBuilder, instancia, estructuraReporte, true); imprimirTituloRol(docBuilder, rolAExportar); Color colorTitulo = Color.FromArgb(ColorTituloTabla[0], ColorTituloTabla[1], ColorTituloTabla[2]); IList <IngresosProductoReporteDto> contenidoTabla = estructuraReporte.IngresosProducto; docBuilder.CurrentSection.PageSetup.LeftMargin = 40; docBuilder.CurrentSection.PageSetup.RightMargin = 40; Table tablaActual = docBuilder.StartTable(); docBuilder.Font.Color = Color.White; docBuilder.ParagraphFormat.SpaceAfter = 0; docBuilder.ParagraphFormat.SpaceBefore = 2; establecerFuenteTituloCampo(docBuilder); docBuilder.Font.Size = TamanioLetraTituloTabla; //Titlo de dimension docBuilder.InsertCell(); docBuilder.RowFormat.HeadingFormat = true; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; docBuilder.CellFormat.HorizontalMerge = CellMerge.None; int iCol = 0; foreach (String columna in MIEMBROS_TIPO_INGRESO) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); docBuilder.CellFormat.WrapText = false; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; if (iCol == 0) { String descPeriodo = (String)estructuraReporte.ParametrosReporte[ID_DIMENSION_TIPO_INGRESO + "_HEADER"]; docBuilder.Write(descPeriodo); docBuilder.CellFormat.HorizontalMerge = CellMerge.First; } else { docBuilder.CellFormat.HorizontalMerge = CellMerge.Previous; } iCol++; } docBuilder.EndRow(); docBuilder.InsertCell(); docBuilder.RowFormat.HeadingFormat = true; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; docBuilder.CellFormat.HorizontalMerge = CellMerge.None; foreach (String columna in MIEMBROS_TIPO_INGRESO) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); docBuilder.CellFormat.WrapText = false; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; String descPeriodo = (String)estructuraReporte.ParametrosReporte[columna + "_HEADER"]; docBuilder.Write(descPeriodo); docBuilder.CellFormat.HorizontalMerge = CellMerge.First; } docBuilder.EndRow(); //Contenido de la tabla establecerFuenteValorCampo(docBuilder); docBuilder.Font.Size = TamanioLetraContenidoTabla; foreach (IngresosProductoReporteDto renglon in contenidoTabla) { docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto; docBuilder.CellFormat.Shading.BackgroundPatternColor = Color.White; docBuilder.CellFormat.WrapText = true; docBuilder.Font.Color = Color.Black; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left; if (renglon.Marca) { docBuilder.Bold = true; docBuilder.Font.Color = Color.White; docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo; docBuilder.ParagraphFormat.LeftIndent = 0; docBuilder.Write(renglon.PrincipalesMarcas); } else if (renglon.Producto) { docBuilder.Bold = false; docBuilder.ParagraphFormat.LeftIndent = 3; docBuilder.Write(renglon.PrincipalesProductos); } else { docBuilder.Write(renglon.PrincipalesProductos); } docBuilder.InsertCell(); docBuilder.RowFormat.HeadingFormat = false; docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Right; docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); if (renglon.IngresosNacionales != null) { escribirLinkNotaAlPie(docBuilder, renglon.IngresosNacionales, estructuraReporte); docBuilder.Write(renglon.IngresosNacionales.ValorFormateado != null ? renglon.IngresosNacionales.ValorFormateado : ""); } docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); if (renglon.IngresosExportacion != null) { escribirLinkNotaAlPie(docBuilder, renglon.IngresosExportacion, estructuraReporte); docBuilder.Write(renglon.IngresosExportacion.ValorFormateado != null ? renglon.IngresosExportacion.ValorFormateado : ""); } docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); if (renglon.IngresosSubsidirias != null) { escribirLinkNotaAlPie(docBuilder, renglon.IngresosSubsidirias, estructuraReporte); docBuilder.Write(renglon.IngresosSubsidirias.ValorFormateado != null ? renglon.IngresosSubsidirias.ValorFormateado : ""); } docBuilder.InsertCell(); docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos); if (renglon.IngresosTotales != null) { escribirLinkNotaAlPie(docBuilder, renglon.IngresosTotales, estructuraReporte); docBuilder.Write(renglon.IngresosTotales.ValorFormateado != null ? renglon.IngresosTotales.ValorFormateado : ""); } docBuilder.EndRow(); } establecerBordesGrisesTabla(tablaActual); docBuilder.EndTable(); }