Formatting issue in Excel to PDF Conversion

@MortenF,
Could you provide your test project, I will improve our SDK package according to your test project.

Hi,
I’ve given up on your SDK. I’m now using pure REST (
​/cells​/{name}​/SaveAs) , but the result is still not honoring page breaks. There’s nothing in the docs about the OnePagePerSheet option. How do I use this in your REST service?

https://reference.aspose.cloud/cells/#/

@MortenF,
Please refer to the following code.

public void TestSaveAsPdfHeaders()
{
const string fileName = “TestExcelTemplate.xlsx”;
ReadyFile(fileName);
var newFileName = Path.ChangeExtension(fileName, “pdf”);
var serverPath = Path.Combine(TempFolderName, newFileName);

        dynamic options = new ExpandoObject();
        options.SaveFormat = "pdf";
        options.CalculateFormula = true;
        options.EnableHTTPCompression = true;
        options.OnePagePerSheet = false;
        options.CreateDirectory = false;
        options.Compliance = "None";

        var url = BuildUrl(string.Format("{0}/SaveAs?folder={1}&newfilename={2}", fileName, TempFolderPath, serverPath));
        string bodyParam = JsonConvert.SerializeObject(options);
        Dictionary<string, string> headParams = null;
        Dictionary<string, object> formParams = null;

        var response = ApiInvoker.InvokeApiAsync<dynamic>(url, "POST", bodyParam, headParams, formParams).Result;
        Assert.AreEqual(HttpStatusCode.OK.ToString(), (string)response.Status.Value);
        Assert.IsNotNull(response.SaveResult);
        Download(serverPath, "TestSaveAsPdfHeaders.pdf");
    }

If you still face the issue, please post your example code and test file here.
I will check it ASAP.

It’s not working (file gets created ok, but no page breaks on second sheet) Why is this even the default? I haven’t had any cases where it’s practical to create pdf without page breaks.

                var posturl = $"https://api.aspose.cloud/v3.0/cells/{name}/SaveAs?newfilename={newname}";
                dynamic options = new ExpandoObject();
                options.SaveFormat = "pdf";
                options.CalculateFormula = true;
                options.EnableHTTPCompression = true;
                options.OnePagePerSheet = false;
                options.CreateDirectory = false;
                options.Compliance = "None";

                var content = JsonConvert.SerializeObject(options);
                var buffer = System.Text.Encoding.UTF8.GetBytes(content);
                var byteContent = new ByteArrayContent(buffer);
                byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
                var result = await client.PostAsync(posturl, byteContent);

https://krpublicfiles.blob.core.windows.net/asposefiles/Boregnskab5010212_73463dd71e12461aa30980fcdd5bbb93.pdf

https://krpublicfiles.blob.core.windows.net/asposefiles/Boregnskab5010212_73463dd71e12461aa30980fcdd5bbb93.xlsx

@MortenF,

Thank you for your provided code and files.
I will check it ASAP and reply.

@MortenF,

Could you provide your Excel file?

They’re both attached in my last reply?

@MortenF,

Thank you. I got them.

BTW the options you provided in the example is completely different from the docs. Where can I find the correct and latest documentation?

@MortenF,

I found the question and created an issue on my tasks that will fix it in version 23.5.
At present, I provide a simple solution to solve this problem, which is to add a query parameter(OnePagePerSheet=false).
Please refer to the following code:

var filename = “forum18727.xlsx”;
var outFilename = “forum18727.pdf”;
ReadyFile(filename);
dynamic options = new ExpandoObject();
options.SaveFormat = “pdf”;
options.CalculateFormula = true;
options.EnableHTTPCompression = true;
options.OnePagePerSheet = false;
options.CreateDirectory = false;
options. Compliance = “None”;

var url = BuildUrl(string.Format("{0}/SaveAs?folder={1}&newfilename={2}&OnePagePerSheet=false", filename, TempFolderPath, outFilename));
string bodyParam = JsonConvert.SerializeObject(options);
Dictionary<string, string> headParams = null;
Dictionary<string, object> formParams = null;

var response = ApiInvoker.InvokeApiAsync(url, “POST”, bodyParam, headParams, formParams).Result;
Assert.AreEqual(HttpStatusCode.OK.ToString(), (string)response.Status.Value);
Assert.IsNotNull(response.SaveResult);
Download(outFilename, “TestCELLSCLOUD18727.pdf”);

@MortenF,
At present, we will improve the documentation as soon as possible to facilitate your use.

Thanks, that’s working.

Now there’s more issues. When testing I I frequently get TaskCanceledException when converting. And there’s pages in the workbook in landscape and portrait mode. All pages are (when it works) created in portrait mode.

Source: https://krpublicfiles.blob.core.windows.net/asposefiles/Forum-Bo-%20og%20panthaverregnskab.xlsx

Result: https://krpublicfiles.blob.core.windows.net/asposefiles/Forum-Bo-%20og%20panthaverregnskab.pdf

@MortenF,
I got your provided files. And I will check them.

@MortenF,

  1. I think there are two reasons cause the task canceled exceptions.
  • The server is saturated with processing power, resulting in a response time greater than the timeout.

  • Network issues that cause response times to be greater than the timeout.

    Now, We are preparing to migrate the Cells Cloud service platform to increase service processing capacity.

  1. We check your provided Excel file. And there is not landscape mode in Excel file.

Thanks,
I have set the timeout in my call to 5 minutes, so that shouldn’t be the problem.

Maybe i have uploaded the wrong file, sorry, I’ll find the right one

@MortenF,

I only think that resource constraints cause task-canceled exceptions.
I want to that the task-canceled exception will decrease after the Cells Cloud service migration is completed.

When do you expect to have upgraded? We can’t use it in production while it’s so unstable. We’re sending emails without any human interaction so it’s crucial that the conversion is working.

@MortenF,
We plan to complete the upgrade this month. I think the upgrade will definitely be completed by next month at the latest.

1 Like

@MortenF,

We have finished switching Cells Cloud Services to Kubernetes Containerize platform.