0

I am working on a project where I use the Aspose.Cells tool. I am inserting information from C#, this information is generated as a table but in reality I do it by means of cells, for which I bring a height and width of columns and rows, so when I upload my original file, all the columns are moved, this is what I don't want to happen so that my original file doesn't lose its format

the following is how I paint my rows and columns

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;

so I need an idea of ​​how to do so that the columns in the original format do not move

it is expected to be as follows

Alexey Noskov
  • 1,722
  • 1
  • 7
  • 13
Isalu
  • 1
  • To evaluate your issue/requirements precisely, we need your sample Excel files (input Excel file(if any), current output Excel file by Aspose.Cells and your expected Excel file) and complete sample code (preferably a standalone VS.NET console application). Please create and zip an archive with required files and other artifacts and provide us. We will then analyze your needs and assist you accordingly soon. By the way, you may also post your issue/requirements in the dedicated forums (https://forum.aspose.com/c/cells/9). PS. I am working as Support developer/ Evangelist at Aspose. – Amjad Sahi Apr 24 '23 at 08:08

0 Answers0