BoldDeskPremium customer service software with affordable pricing: $10 for 3 agents. Try it for free.
private void OpenFile(Rapport rapport)
{
using (ClientContext client = new ClientContext(SharePointSettings.SiteUrl))
{
File.OpenBinaryDirect(client, "/Rapporten/Uitvoeringsdetail.xlsx", (s, r) =>
{
try
{
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open(r.Stream,ExcelOpenType.SpreadsheetML2010);
//IWorksheet sheet = workbook.ActiveSheet;
//sheet.Range["klant"].Value = _uitvoering.Order.Project.Klant;
//sheet.Range["tel"].Value = _uitvoering.Order.Project.ContactGsm;
//sheet.Range["adres"].Value = string.Format("{0} {1} {2}", _uitvoering.Order.Project.Adres,
// _uitvoering.Order.Project.Postcode,
// _uitvoering.Order.Project.Plaats);
//int counter = 1;
//foreach (OrderDetail orderDetail in _uitvoering.Order.OrderDetails)
//{
// if (orderDetail.Uitvoeren)
// {
// try
// {
// sheet.Range[sheet["type"].Row + counter, sheet["type"].Column].Value = orderDetail.Type;
// sheet.Range[sheet["omschrijving"].Row + counter, sheet["omschrijving"].Column].Value = orderDetail.Omschrijving;
// sheet.Range[sheet["opp"].Row + counter, sheet["opp"].Column].Value = ItemValue.ToString(orderDetail.M2Uitvoeren);
// sheet.Range[sheet["dikte"].Row + counter, sheet["dikte"].Column].Value = ItemValue.ToString(orderDetail.Dikte);
// counter++;
// }
// catch (Exception exception)
// {
// throw new Exception("Error bij in instellen van de rapportlijnen", exception);
// }
//}
//}
using (MemoryStream stream = new MemoryStream())
{
List documentList = client.Web.Lists.GetByTitle("Gedeelde documenten");
workbook.SaveAs(stream);
var fileCreation = new FileCreationInformation();
fileCreation.Content = stream.ToArray();
fileCreation.Overwrite = true;
fileCreation.Url = string.Format("{0}.xlsx", _uitvoering.UitvoeringNr);
File file = documentList.RootFolder.Files.Add(fileCreation);
client.Load(file);
client.ExecuteQueryAsync((s1, r1) => Deployment.Current.Dispatcher.BeginInvoke(() => OpenDocument(file.ServerRelativeUrl, client.Url)), (s1, r1) => { });
}
}
catch (Exception exception)
{
throw new Exception("Error bij rapport", exception);
}
}, (s, r) =>
{
});
}
}
Anyone what am I doing wrong?
Hi steve mangelschots,
Thank you for using the Syncfusion Product,
From your code snippet, we could see that you are using the input file “Uitvoeringsdetail.xlsx”. We suspect that issue could be reproduced when try to get the range value from the workbook. So, could you please update the input file or issue reproduced sample. And also we have found the usage issue from your code, before save the workbook as stream please change the workbook version as Excel 2010.
Please let us know if you have any clarification,
Thanks and Regards,
Rajesh A.