To improve performance of writing workbook with multiple worksheets, we are using parallel each while writing worksheets. We are getting object reference not set to an instance while doing workbook.save method.
We are trying to run this on AWS Lambda which is linux based.
following is our sample code
Workbook workbook= new Workbook();
for (int i = 1; i < worksheetCount; i++)
var result = Parallel.ForEach(workbook.Worksheets,
CreateWorksheet(rowCount, sheet.Index, ref sheet);
Console.WriteLine("Created parallel worksheets : " + stopwatch.Elapsed);
using (MemoryStream stream = new MemoryStream())
LambdaLogger.Log("Saved report to memory stream : " + stopwatch.Elapsed);
PutObjectRequest request = new PutObjectRequest
BucketName = Environment.GetEnvironmentVariable(“ReportDocumentsBucket”),
Key = filename,
InputStream = stream
LambdaLogger.Log("Report uploaded to S3 bucket, Total Upload Time : " + stopwatch.Elapsed);
catch (Exception exception2)