导入excel,导入成功后,点击保存,保存到
然后打开保存位置的excel和之前导入的对比,发现保存的和原来的格式不一致 现在想要实现的就是,保存的能和原先的格式保持一致 下图是保存后打开的样式,与最上面导入在线预览的样式不一致
这是保存事件的代码:
- Exporter excelExporter = new Exporter(this.HiddenField2.Value);
- MemoryStream stream = new MemoryStream();
- excelExporter.SaveExcel(stream);
- byte[] bts = new byte[stream.Length];
- stream.Read(bts, 0, (int)stream.Length);
- //FileStream fs = new FileStream("D:\\test.xlsx", FileMode.OpenOrCreate);
- //BinaryWriter w = new BinaryWriter(fs);
- //w.Write(stream.ToArray());
- //fs.Close();
- //stream.Close();
- string url = "/upload/预算价格计算-20160722142227-钢构材料价格表.xlsx";
- if (url != null && url != "")
- {
- FileStream fs = new FileStream(Server.MapPath(url), FileMode.OpenOrCreate);
- BinaryWriter w = new BinaryWriter(fs);
- w.Write(stream.ToArray());
- fs.Close();
- stream.Close();
- Page.RegisterStartupScript("string key", "<script>alert('操作成功 !');window.close();</script>"); ;
- }
复制代码
|