[
  {
    "Id": "652512",
    "ThreadId": "267770",
    "Html": "<p>hi</p>\n<p>how can i read an excel file from a memory stream &amp; then zip it.. i tried the below code but error occured..</p>\n<p>\n<div style=\"color: black; background-color: white;\">\n<pre><span style=\"color: blue;\">if</span> (sfdExcel.ShowDialog() != DialogResult.Cancel)\n    {\n        <span style=\"color: blue;\">string</span> file_save_name = sfdExcel.FileName;\n       <span style=\"color: blue;\">string</span> file_save_name_pre = file_save_name.Substring(0, file_save_name.Length - 4);\n       <span style=\"color: blue;\">using</span> (MemoryStream memory = <span style=\"color: blue;\">new</span> MemoryStream())\n             {\n                  hssfworkbook.Write(memory);\n                  <span style=\"color: blue;\">using</span> (ZipFile zip = <span style=\"color: blue;\">new</span> ZipFile())\n                     {\n                      ZipEntry e = zip.AddEntry(<span style=\"color: #a31515;\">\"report.xls\"</span>, memory);\n                       zip.AddFile(file_save_name_pre + <span style=\"color: #a31515;\">\".xls\"</span>);\n                        zip.Save(file_save_name_pre + <span style=\"color: #a31515;\">\".zip\"</span>);\n                      }\n               }\n         MessageBox.Show(<span style=\"color: #a31515;\">\"Report Saved\"</span>, MessageBoxButtons.OK);\n     }\n</pre>\n</div>\n</p>\n<p>I think i am not using the package the right way... what should i do ??</p>\n<p>Thanks in advance.</p>\n<p>&nbsp;</p>\n<p>&nbsp;</p>",
    "PostedDate": "2011-08-04T09:50:44.96-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "652586",
    "ThreadId": "267770",
    "Html": "<p>i have solved the problem partially.. the below code is working but it is saving the whole directory structure...</p>\n<div style=\"color: black; background-color: white;\">\n<pre><span style=\"color: blue;\">if</span> (sfdExcel.ShowDialog() != DialogResult.Cancel)\n                            {\n           <span style=\"color: blue;\">string</span> file_save_name = sfdExcel.FileName;\n         <span style=\"color: blue;\">string</span> file_save_name_pre = file_save_name.Substring(0, file_save_name.Length - 4);\n      <span style=\"color: blue;\">using</span> (MemoryStream memory = <span style=\"color: blue;\">new</span> MemoryStream())\n              {\n                  hssfworkbook.Write(memory); \n                   <span style=\"color: blue;\">byte</span>[] contents = memory.ToArray();\n                   <span style=\"color: blue;\">using</span> (ZipFile zip = <span style=\"color: blue;\">new</span> ZipFile())\n                     {\n                       ZipEntry e = zip.AddEntry(file_save_name_pre + <span style=\"color: #a31515;\">\".xls\"</span>, contents);\n                 zip.Save(file_save_name_pre + <span style=\"color: #a31515;\">\".zip\"</span>);\n                          }\n                       }\n               MessageBox.Show(<span style=\"color: #a31515;\">\"Report Saved\"</span>, MessageBoxIcon.Information);\n            }</pre>\n<pre>what should i do now??</pre>\n</div>",
    "PostedDate": "2011-08-04T11:24:11.493-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "652598",
    "ThreadId": "267770",
    "Html": "<p>okay.. i got it finally.. :)</p>\n<p>&nbsp;</p>\n<div style=\"color: black; background-color: white;\">\n<pre><span style=\"color: blue;\">if</span> (sfdExcel.ShowDialog() != DialogResult.Cancel)\n   {\n     <span style=\"color: blue;\">string</span> file_save_name = sfdExcel.FileName;\n     <span style=\"color: blue;\">string</span> file_save_name_pre = <span style=\"color: blue;\">new</span> FileInfo(file_save_name).Name;\n     <span style=\"color: blue;\">string</span> file_save_path = file_save_name.Substring(0, file_save_name.Length - 4);\n     <span style=\"color: blue;\">using</span> (MemoryStream memory = <span style=\"color: blue;\">new</span> MemoryStream())\n           {\n               hssfworkbook.Write(memory);\n               <span style=\"color: blue;\">byte</span>[] contents = memory.ToArray();\n               <span style=\"color: blue;\">using</span> (ZipFile zip = <span style=\"color: blue;\">new</span> ZipFile())\n                     {\n             ZipEntry e = zip.AddEntry(file_save_name_pre, contents);\n               zip.Save(file_save_path + <span style=\"color: #a31515;\">\".zip\"</span>);\n                      }\n            }\n     MessageBox.Show(<span style=\"color: #a31515;\">\"Report Saved\"</span>,MessageBoxIcon.Information);\n   }</pre>\n</div>",
    "PostedDate": "2011-08-04T11:41:10.94-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "652628",
    "ThreadId": "267770",
    "Html": "<p>oh, good!&nbsp; You answered your own question!&nbsp; Glad you got it.</p>",
    "PostedDate": "2011-08-04T12:45:14.75-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]