在不影响其他列的情况下自动调整一系列单元格中的列

问题描述 投票:0回答:0

我正在做一个使用 aspose 单元格工具的项目。我从 C# 中插入信息,此信息是作为表格生成的,但实际上我是通过单元格来完成的,为此我带来了列和行的高度和宽度,因此当我上传原始文件时,所有列都是感动,这是我不想发生的事情,这样我的原始文件就不会丢失它的格式

以下是我如何绘制行和列

cells[fila, ultimacolumna].Value = item.TipoAprovador;
                                        Aspose.Cells.Style style2 = cells[fila, ultimacolumna].GetStyle();
                                        style2.Font.IsBold = true;
                                        style2.HorizontalAlignment = TextAlignmentType.Center;
                                        style2.VerticalAlignment = TextAlignmentType.Center;
                                        style2.Font.Size = 13;
                                        style2.IsTextWrapped = true;
                                        style2.Borders[Aspose.Cells.BorderType.TopBorder].LineStyle = CellBorderType.Medium;
                                        style2.Borders[Aspose.Cells.BorderType.TopBorder].Color = Color.Black;
                                        style2.Borders[Aspose.Cells.BorderType.LeftBorder].LineStyle = CellBorderType.Medium;
                                        style2.Borders[Aspose.Cells.BorderType.LeftBorder].Color = Color.Black;
                                        style2.Borders[Aspose.Cells.BorderType.RightBorder].LineStyle = CellBorderType.Medium;
                                        style2.Borders[Aspose.Cells.BorderType.RightBorder].Color = Color.Black;
                                        cells[fila, ultimacolumna].SetStyle(style2);
                                        cells.SetRowHeight(fila, 60);
                                        cells.SetColumnWidth(ultimacolumna, 50);

                                        //Firma
                                        if (respTipoDocumento.FirmaAutUserName == 1)
                                        {
                                            MemoryStream stream = new MemoryStream(FirmaResized);

                                            int pictureIndex = worksheet.Pictures.Add(fila + 1, ultimacolumna, stream);
                                            Aspose.Cells.Drawing.Shape pic = worksheet.Pictures[pictureIndex];
                                            pic.Left = 110;
                                            pic.Top = 20;

                                            Aspose.Cells.Style style5 = cells[fila + 1, ultimacolumna].GetStyle();
                                            style5.Font.IsBold = true;
                                            style5.HorizontalAlignment = TextAlignmentType.Center;
                                            style5.VerticalAlignment = TextAlignmentType.Center;
                                            style5.Font.Size = 13;
                                            style5.IsTextWrapped = true;
                                            style5.Borders[Aspose.Cells.BorderType.LeftBorder].LineStyle = CellBorderType.Medium;
                                            style5.Borders[Aspose.Cells.BorderType.LeftBorder].Color = Color.Black;
                                            style5.Borders[Aspose.Cells.BorderType.RightBorder].LineStyle = CellBorderType.Medium;
                                            style5.Borders[Aspose.Cells.BorderType.RightBorder].Color = Color.Black;
                                            cells[fila + 1, ultimacolumna].SetStyle(style5);

                                            cells.SetRowHeight(fila + 1, 90);
                                            cells.SetColumnWidth(ultimacolumna, 50);
                                        }
                                        if (respTipoDocumento.FirmaAutUserName == 2)
                                        {
                                            cells[fila + 1, ultimacolumna].Value = item.Username;

                                            Aspose.Cells.Style style5 = cells[fila + 1, ultimacolumna].GetStyle();
                                            style5.Font.IsBold = true;
                                            style5.HorizontalAlignment = TextAlignmentType.Center;
                                            style5.VerticalAlignment = TextAlignmentType.Center;
                                            style5.Font.Size = 13;
                                            style5.IsTextWrapped = true;
                                            style5.Borders[Aspose.Cells.BorderType.LeftBorder].LineStyle = CellBorderType.Medium;
                                            style5.Borders[Aspose.Cells.BorderType.LeftBorder].Color = Color.Black;
                                            style5.Borders[Aspose.Cells.BorderType.RightBorder].LineStyle = CellBorderType.Medium;
                                            style5.Borders[Aspose.Cells.BorderType.RightBorder].Color = Color.Black;
                                            cells[fila + 1, ultimacolumna].SetStyle(style5);


                                            cells.SetRowHeight(fila + 1, 60);
                                            cells.SetColumnWidth(ultimacolumna, 50);
                                        }
                                        if (respTipoDocumento.FirmaAutUserName == 3)
                                        {
                                            byte[] imgQR = GenerarQR((int)DocumentoOriginal.SolicitudId, (int)item.UsuarioId, item.TipoAprovadorId);
                                            MemoryStream stream = new MemoryStream(imgQR);
                                            int pictureIndex = worksheet.Pictures.Add(fila + 1, ultimacolumna, stream);
                                            Aspose.Cells.Drawing.Shape pic = worksheet.Pictures[pictureIndex];
                                            pic.Left = 110;
                                            pic.Top = 20;

                                            Aspose.Cells.Style style5 = cells[fila + 1, ultimacolumna].GetStyle();
                                            style5.Font.IsBold = true;
                                            style5.HorizontalAlignment = TextAlignmentType.Center;
                                            style5.VerticalAlignment = TextAlignmentType.Center;
                                            style5.Font.Size = 13;
                                            style5.IsTextWrapped = true;
                                            style5.Borders[Aspose.Cells.BorderType.LeftBorder].LineStyle = CellBorderType.Medium;
                                            style5.Borders[Aspose.Cells.BorderType.LeftBorder].Color = Color.Black;
                                            style5.Borders[Aspose.Cells.BorderType.RightBorder].LineStyle = CellBorderType.Medium;
                                            style5.Borders[Aspose.Cells.BorderType.RightBorder].Color = Color.Black;
                                            cells[fila + 1, ultimacolumna].SetStyle(style5);


                                            cells.SetRowHeight(fila + 1, 90);
                                            cells.SetColumnWidth(ultimacolumna, 50);
                                        }



                                        cells[fila + 2, ultimacolumna].Value = item.NombreCompleto;
                                        Aspose.Cells.Style style3 = cells[fila + 2, ultimacolumna].GetStyle();
                                        style3.Font.IsBold = true;
                                        style3.HorizontalAlignment = TextAlignmentType.Center;
                                        style3.VerticalAlignment = TextAlignmentType.Center;
                                        style3.Font.Size = 13;
                                        style3.IsTextWrapped = true;
                                        style3.Borders[Aspose.Cells.BorderType.LeftBorder].LineStyle = CellBorderType.Medium;
                                        style3.Borders[Aspose.Cells.BorderType.LeftBorder].Color = Color.Black;
                                        style3.Borders[Aspose.Cells.BorderType.RightBorder].LineStyle = CellBorderType.Medium;
                                        style3.Borders[Aspose.Cells.BorderType.RightBorder].Color = Color.Black;
                                        cells[fila + 2, ultimacolumna].SetStyle(style3);
                                        cells.SetRowHeight(fila + 2, 60);
                                        cells.SetColumnWidth(ultimacolumna, 50);

                                        //Puesto
                                        cells[fila + 3, ultimacolumna].Value = item.Puesto;
                                        Aspose.Cells.Style style4 = cells[fila + 3, ultimacolumna].GetStyle();
                                        style4.Font.IsBold = true;
                                        style4.HorizontalAlignment = TextAlignmentType.Center;
                                        style4.VerticalAlignment = TextAlignmentType.Center;
                                        style4.Font.Size = 13;
                                        style4.IsTextWrapped = true;
                                        style4.Borders[Aspose.Cells.BorderType.LeftBorder].LineStyle = CellBorderType.Medium;
                                        style4.Borders[Aspose.Cells.BorderType.LeftBorder].Color = Color.Black;
                                        style4.Borders[Aspose.Cells.BorderType.RightBorder].LineStyle = CellBorderType.Medium;
                                        style4.Borders[Aspose.Cells.BorderType.RightBorder].Color = Color.Black;
                                        style4.Borders[Aspose.Cells.BorderType.BottomBorder].LineStyle = CellBorderType.Medium;
                                        style4.Borders[Aspose.Cells.BorderType.BottomBorder].Color = Color.Black;
                                        cells[fila + 3, ultimacolumna].SetStyle(style4);
                                        cells.SetRowHeight(fila + 3, 60);
                                        cells.SetColumnWidth(ultimacolumna, 50);

                                        ultimacolumna = ultimacolumna + 1;

enter image description here

所以我需要知道如何使原始格式的列不移动

预计如下

enter image description here

c# asp.net cell aspose
© www.soinside.com 2019 - 2024. All rights reserved.