Async RadSpreadStreamProcessing

1 Answer 49 Views
SpreadStreamProcessing
Caesar
Top achievements
Rank 1
Caesar asked on 25 May 2022, 06:44 AM

Are there any plans of making async functions in RadSpreadStreamProcessing?

When used in a server environment, that would increase throughput of requests a lot...

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 26 May 2022, 09:46 AM

Hello Rikard,

Can you provide more information about your requirement? Do you want to prevent the UI from freezing you want to export the documents parallelly? 

In general, you can execute the entire process on a separate thread. For example:

class AsyncSpredStreamTest
{
    public async Task PerfromExport()
    {
        for (int i = 0; i < 100; i++)
        {
            await this.ExportAsync("Data" + i, "File" + i + ".xlsx");
        }
    }
    private async Task ExportAsync(string data, string fileName)
    {
        await Task.Run(() =>
        {
            using (FileStream stream = File.OpenWrite(fileName))
            {
                using (IWorkbookExporter workbook = SpreadExporter.CreateWorkbookExporter(SpreadDocumentFormat.Xlsx, stream))
                {
                    using (IWorksheetExporter worksheet = workbook.CreateWorksheetExporter("My sheet"))
                    {
                        for (int i = 0; i < 100; i++)
                        {
                            using (IRowExporter row = worksheet.CreateRowExporter())
                            {
                                for (int j = 0; j < 1000; j++)
                                {
                                    using (ICellExporter cell = row.CreateCellExporter())
                                    {
                                        cell.SetValue(data);

                                    }
                                }
                            }
                        }
                    }
                }
            }
        });
    }
}

I am looking forward to your reply.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Caesar
Top achievements
Rank 1
commented on 27 May 2022, 06:30 AM

We are developing a server web API that is writing the excel directly to the output stream. But I just realized that we cannot write directly to the response output stream anyway (it is not seekable), so I had to create the excel file in a temporary memorystream and then copy that memory stream to the response stream, so there is no need for async when using this library...
Dimitar
Telerik team
commented on 27 May 2022, 08:12 AM

I am glad that you have found a solution for your case.

Do not hesitate to contact us if you have other questions.
Tags
SpreadStreamProcessing
Asked by
Caesar
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or