Tag: asp.net

OpenXml,独立存储和大文件大小

我正在使用OpenXML在Web应用程序中生成Excel文档。 它对文件<〜10mb很好 对于大于10MB的文件生成的文件,我得到以下exception… 虽然我在网上对这个问题进行了一些讨论(有些关于使用其他包装库),但我还没有解决我们的问题。 其他人看到并解决了这个问题? 我真的很喜欢使用OpenXml的想法(但是由于这个问题,我讨厌转向另一种解决scheme) 解决scheme? System.IO.IsolatedStorage.IsolatedStorageException:无法创build商店目录。 (System.IO.IsolatedStorage.IsolatedStorageFile.GetRootDir(IsolatedStorageScope范围,StringHandleOnStack retRootDir)在System.IO.IsolatedStorage.IsolatedStorageFile.InitGlobalsNonRoamingUser(IsolatedStorageScope范围)System.IO.IsolatedStorage.IsolatedStorageFile.GetRootDir(IsolatedStorageScope范围)中的(从HRESULTexception:0x80131468)范围)在System.IO.IsolatedStorage.IsolatedStorageFile.GetStore上的System.IO.IsolatedStorage.IsolatedStorageFile.GetGlobalFileIOPerm(IsolatedStorageScope范围)System.IO.IsolatedStorage.IsolatedStorageFile.Init(IsolatedStorageScope范围)(IsolatedStorageScope范围,typesdomainEvidenceType,typesassemblyEvidenceType)在MS.Internal.IO.Packaging.PackagingUtilities.ReliableIsolatedStorageFileFolder.GetCurrentStore()

将Excel工作表数据存储到SQL Server

我收到类似的错误消息 初始化string的格式不符合从索引0开始的规范。 导出Excel文件时。 请指教 这是我的代码: string file = string.Format("{0}\\{1}", Request.PhysicalApplicationPath,Guid.NewGuid().ToString().Replace("-",string.Empty)); fileuploadExcel.SaveAs(file); //Create connection string to Excel work book string excelConnectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 12.0;HRD=YES;IMEX=1'", fileuploadExcel.PostedFile.FileName); //Create Connection to Excel work book OleDbConnection excelConnection =new OleDbConnection(file); //Create OleDbCommand to fetch data from Excel OleDbCommand cmd = new OleDbCommand("Select [ID],[Name],[Desi] from [Varun]", excelConnection); excelConnection.Open(); OleDbDataReader dReader; […]

导出到excel工作在本地但不在服务器上

我知道很多论坛上这样的问题很多次被问到,但是让这个问题变得陌生的事情是,它在本地和服务器上的一个模块工作,而不是另一个模块。 让我更清楚。 我出口一个模块的Excel表格,说CS使用以下代码 public void ExportToExcel(string fileName, GridView gv) { try { HttpContext.Current.Response.ClearContent(); HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.xls", fileName)); HttpContext.Current.Response.ContentType = "application/excel"; System.IO.StringWriter sw = new System.IO.StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); gv.RenderControl(htw); HttpContext.Current.Response.Write(sw.ToString()); HttpContext.Current.Response.End(); } catch (Exception ex) { } } 并导出另一个列表说,零售商使用相同的代码。 我debugging本地和第二个模块,它是一个例外 ThreadAbortException但是一个logging列表。 正如我在这里build议我使用HttpContext.Current.ApplicationInstance.CompleteRequest但得到意想不到的结果(整个页面expoted)

使用颜色代码从Gridview导出为Excel

我在GridView使用基于一些百分比逻辑的颜色代码。 但是,导出到Excel我不知道如何维护Excel中的这种颜色代码。 请指导 以下是RowDataBound的代码 protected void Grd_QADetails_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var dataRowView = e.Row.DataItem as DataRowView; DataRow row = dataRowView.Row; var Current = (row["Current Month Percentage"] as double?) ?? null; double? Yellow = (double?)Convert.ToDouble(row["Yellow"]); double? Green = (double?)Convert.ToDouble(row["Green"]); if (Current != null) { if (Current >= Green) e.Row.Cells[6].BackColor = […]

在ASP.NET中将DataTable导出到Excel

当调用这个方法时,整个htmldevise的页面随着数据移植到excel。 我只想要导出数据,不应该使用htmldevise。 我无法find解决scheme,请有人帮助解决。 public void ExportToExcel(DataTable dtExportData) { string strReportName = string.Empty; //StringWriter oStringWriter = null; //Html32TextWriter oHtmlTextWriter = null; //TableOneDayPassReport.Visible = true; ExcelGrid.EnableViewState = false; ExcelGrid.DataSource = dtExportData; ExcelGrid.DataBind(); Response.Clear(); Response.ClearHeaders(); Response.Cache.SetCacheability(HttpCacheability.Private); Response.AddHeader("content-disposition", "attachment;filename=OwnTransportDetails.xls"); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); //TableOneDayPassReport.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); //Response.End(); // […]

保存excel文件的选项

我使用Microsoft.Office.Interop.Excel;从网页上点击button生成一个excel文件Microsoft.Office.Interop.Excel; 。现在我得到的问题是生成的文件被保存到系统的本地磁盘。意味着path硬编码..这里是我的代码。 object objOpt = Missing.Value; objBook.SaveAs(@"D:\SampleChart.xls", objOpt, objOpt, objOpt, objOpt, objOpt, XlSaveAsAccessMode.xlNoChange, objOpt, objOpt, objOpt, objOpt, objOpt); objBook.Close(false, objOpt, objOpt); 所以我的问题是我怎样才能从浏览器保存这个Excel文件。 提前致谢..

导出一个带有链接button的gridview到excel

我有一个与Onclick事件链接button的GridView打开.pdf文件。 文件path是在.aspx页面的Onclick事件调用的后台代码中dynamic生成的。 我能够出口到excel罚款。 该列作为超链接而来。 但我的问题是Onclick事件没有启用,或者没有得到与其他数据一起导出到Excel文件。 在我的GridView(名为GVActiveMEOs)中,我将DataKeyNames设置为DataKeyNames="MEO_NR" 。 而在asp:TemplateField里面我有这个asp:LinkButton <asp:linkbutton id="lnk" runat="server" onclick="OpenMEO" commandargument='<%# Eval("MEO_NR") %>' text='<%# Eval("MEO_NR") %>'> </asp:linkbutton> 代码隐藏 Protected Sub OpenMEO(ByVal sender As Object, ByVal e As EventArgs) Dim strConnString As String = ConfigurationManager.ConnectionStrings("AEM_ESS001_DEVConnectionString").Connect‌​ionString Dim con As New SqlConnection(strConnString) Dim cmd As New SqlCommand Dim MPath As String 'Dim index As Integer = […]

从HRESULT:0x800A03EC获取exception,同时在Excel工作簿中添加新工作表

同时在Excel工作簿中添加一个新工作表,我从HRESULTexception:0x800A03EC: Microsoft.Office.Interop.Excel._Workbook m_objBook = null; object m_objOpt = "Test"; m_objBook = (Microsoft.Office.Interop.Excel._Workbook)(m_objBooks.Add(m_objOpt)); m_objSheets = (Microsoft.Office.Interop.Excel.Sheets)m_objBook.Worksheets; m_objSheet1 = (Microsoft.Office.Interop.Excel._Worksheet)(m_objSheets.get_Item(1)); m_objSheet1.Name = "Project List"; m_objSheet2 = (Microsoft.Office.Interop.Excel._Worksheet)(m_objSheets.get_Item(2)) m_objSheet2.Name = "Project Status"; m_objSheet3 = (Microsoft.Office.Interop.Excel._Worksheet)(m_objSheets.get_Item(3)); m_objSheet3.Name = "Pending items"; 在下面一行我得到错误 – exception来自HRESULT:0x800A03EC m_objSheet4 = (Microsoft.Office.Interop.Excel._Worksheet)(m_objSheets.Add (m_objOpt, m_objSheet3, 1, m_objOpt)); m_objSheet4 = (Microsoft.Office.Interop.Excel._Worksheet)(m_objSheets.get_Item(4)); m_objSheet4.Name = "NewSheet";

如何将excel表导入到asp.net中的sql数据库

我试图从xls格式文件保存数据在sql数据库。我已经尝试了下面的代码,但它显示错误,外部表格不是在预期的格式。任何人都可以帮助我如何保存数据从xls格式文件到数据库? code: protected void Button1_Click(object sender, EventArgs e) { string sheet1 = "asdf"; string path = MapPath("~/dataWorldcup/asdf.xls"); OleDbConnection oconn1 = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;"); OleDbCommand ocmd = new OleDbCommand("select * from [" + sheet1 + "$]", oconn1); SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["consed"].ConnectionString); oconn1.Open(); sqlcon.Open(); OleDbDataReader odr = ocmd.ExecuteReader(); SqlBulkCopy sqlBulk […]

C# – Excel / InteropServicesreplace方法遇到问题

所以search已经返回了如何使用Replace方法的一些结果,但我还没有得到任何工作。 希望你们能帮助我指出正确的方向! 这是我的。 我调用Replace方法时出现错误。 我怀疑我正在做一些错误的范围,但我不确定。 private Process DoExcelWork(Process excelProc, string filePath) { // Initialize Excel Application Excel.Application excelApp = new Excel.Application(); excelApp.Visible = false; // Get the process Process[] possibleProcesses = Process.GetProcessesByName("Excel"); excelProc = possibleProcesses[0]; // Empty Object for optional arguments object optional = System.Reflection.Missing.Value; Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(filePath, optional, optional, optional, optional, optional, optional, […]