Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From a quick glance, I think you are making a couple mistakes. First it seems you are trying to send the image and the excel through the response. I don't believe you can send multiple files to the client, but you don't need to send the image anyways since you are just inserting it into the excel file. Also with the image you are attempting to load the bitmap from the non-existent server file "chart.bmp". Second, you are using the function <code>Response.WriteFile</code> which writes a disk file to the response. I'm guessing that's not what you are trying to do since you have already written the file to the response with <code>Package.SaveAs</code>. Try this code below, </p> <pre><code> 'Save the chart to a memory stream instead of a file Dim BitMapMS As New MemoryStream Chart1.SaveImage(BitMapMS) 'Load bitmap from memory stream Dim imgchart As Bitmap imgchart = New Bitmap(BitMapMS) Using package As New ExcelPackage(newFile) ' add a new worksheet to the empty workbook Dim worksheet As ExcelWorksheet = package.Workbook.Worksheets.Add("LIMS") 'Add the headers worksheet.Cells(1, 1).Value = "Analyzer Time" worksheet.Cells(1, 2).Value = "Analyzer Data" worksheet.Cells(1, 3).Value = "Lab Date" worksheet.Cells(1, 4).Value = "Lab Data" Dim row row = 2 For i = 0 To count1 - 1 worksheet.Cells(row, 1).Value = col1(i) worksheet.Cells(row, 2).Value = col2(i) row = row + 1 Next row = 2 For i = 0 To labcount - 1 worksheet.Cells(row, 3).Value = col3(i) worksheet.Cells(row, 4).Value = col4(i) row = row + 1 Next worksheet.Drawings.AddPicture("chart", imgchart) 'Clear the response Response.Clear() Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" Response.AppendHeader("Content-Disposition", "attachment;filename=chart.xlsx") 'This call looks like it will write the data to the stream. package.SaveAs(Response.OutputStream) Response.End() End Using </code></pre> <p>I can't test the above code, so give it a try and let us know how it goes.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload