Hello there!
I’m facing an issue regarding the convertion of a xlsm file into pdf.
The code consists of two steps:
1. I copy one worksheet from one excel file to another (both at the same location).
2. Then, I generate a pdf file based only on the first worksheet of the second excel file.
Important notes:
- The second file contains three sheets, one of them with graphs and the others with data, in which the graphs are based on.
The thing is, when I copy the worksheet from one excel file to the other, it works file. I use the Workbook.Save() method to save and all the data and graphs are OK!
However, when I save this sheet into pdf, it kinda “misunderstand” its references and some values contains old inputs. I then used a method called CalculateFormula() that forces the update of those values, but it causes the other values to get #REF values.
I noticed that those #REF values are referencing the other sheet, like ‘D:\Bizagi\Projects\1…!sheetnameCellvalue’.
I don’t want to reference the other sheet, all I wanted was to copy the data from one sheet to another.
One point to take into consideration is that the conversion works fine locally, but when I try to use it on a remote server, this issue happens.
Things are kinda hectic in this project, so I didn’t have much spare time to do a better search through the forums in order to find a way out of this. But so far, I couldn’t find anything that helped.
One point to take into consideration is that the conversion works fine locally, but when I try to use it on a remote server, this issue happens.
Things are kinda hectic in this project, so I didn’t have much spare time to do a better search through the forums in order to find a way out of this. But so far, I couldn’t find anything that helped.
Here’s the code:
string caminhoPara = “Relatorio_teste.xlsm”;
Aspose.Cells.Workbook excelWorkbook1 = new Aspose.Cells.Workbook(caminhoDe);
Aspose.Cells.Workbook excelWorkbook2 = new Aspose.Cells.Workbook(caminhoPara);
excelWorkbook2.Worksheets[1].Copy(excelWorkbook1.Worksheets[“SaidaMatlab”]);
excelWorkbook2.CalculateFormula(true);
excelWorkbook2.Save(caminhoPara);
for (int i = 1; i < excelWorkbook2.Worksheets.Count; i++)
{
excelWorkbook2.Worksheets[i].IsVisible = false;
}
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.OnePagePerSheet = true;
excelWorkbook2.Worksheets[i].IsVisible = false;
}
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.OnePagePerSheet = true;
excelWorkbook2.Save(“Relatório Final.pdf”, pdfSaveOptions);