Tag: asp.net

当我想获得excel导出,Button_click什么都不做ASP.NET C#

当我试图从我的mysqldatabase获取excel导出时,它不会对button_click执行任何操作。 我可以看到,gridview是由DataTable填写,但在回发它不下载我gridview的excel输出。我无法找出问题出在哪里。 感谢您帮助球员。 这是我的.aspx网格视图代码 <asp:GridView ID="GridView1" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White" RowStyle-BackColor="#A1DCF2" AlternatingRowStyle-BackColor="White" AlternatingRowStyle-ForeColor="#000" runat="server" AutoGenerateColumns="false" AllowPaging="true" OnPageIndexChanging="OnPageIndexChanging"> <Columns> <asp:BoundField DataField="isbn" HeaderText="isbn" ItemStyle-Width="150px" /> <asp:BoundField DataField="display_name" HeaderText="bookName" ItemStyle-Width="100px" /> <asp:BoundField DataField="authorName" HeaderText="authorName" ItemStyle-Width="100px" /> </Columns> 这是我的数据绑定和button点击 private void BindGrid() { DataTable dt = book.getAllbookExcelExport(); GridView1.DataSource = dt; GridView1.DataBind(); } protected void btnExport_ServerClick(object sender, EventArgs e) { Response.Clear(); Response.Buffer […]

导出使用HttpContext.Current.Response是造成问题

我正在开发一个使用asp.net/C#/HTML5/bootstrap的网站。 其中一个要求是将文档导出为Excel和/或PDF。 我能够导出(成功)使用以下代码片段(这是Excel代码段): HttpContext.Current.Response.ContentType = "application/octet-stream"; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8; HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + filename); HttpContext.Current.Response.BinaryWrite(xlsBytes); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.End(); 我遇到的问题是,在运行之后,似乎是停止页面生命周期中的轨道。 作为一个例子,用户点击导出button,调用JavaScript抛出一个“请稍候”模式对话框,并提交表单: <script src="../Scripts/waitingFor.js"></script> <script type="text/javascript"> function pleaseWait() { waitingDialog.show("Building File<br/>…this could take a minute", { dialogSize: "sm", progressType: "warning" }); form = document.getElementById("frm_contentMaster"); form.submit(); } </script> javascript包含文件: /** * Module for displaying "Waiting for…" dialog using Bootstrap […]

在Asp.Net中导入Excel工作表

我需要问与父母关系导入Excel表单问题。 下面我有一个示例表 那么我需要导入这个表格就像这种格式 – > IndustryName | IndustryCode | CategoryName | CategoryCode | CategoryValue | SubCategoryName | SubCategoryCode | SubCategoryValue IndustryName1 IndustCode CatName CatCode CatValue SubCatName SubCatCode SubCatValue IndustryName1 IndustCode CatName CatCode CatValue SubCatName SubCatCode SubCatValue 在子分类行上在SubCategoryCode.Its固定的前面有两个空格。 任何人有一个想法,我怎么能做到这一点?

在Excel上将Excel导入Json格式

我需要问与父母关系导入Excel表单问题。 下面我有一个示例表 输出我想要那样 [{"Code":"888800","Title":"Category","Value":"123","Children":[]}, {"Code":"100000","Title":"Category1","Value":"123","Children": [ {"Code":"120000","Title":"SubCategory","Value":"123","Children":[]}, {"Code":"352000","Title":"SubCategory2","Value":"123","Children":[]}, {"Code":"200000","Title":"SubCategory3","Value":"123","Children":[]}, ]}, {"Code":"212101","Title":"Category3","Value":"123","Children": [ {"Code":"213100","Title":"SubCategory4","Value":"123","Children":[]}, {"Code":"213200","Title":"SubCategory4","Value":"123","Children":[]} ]} ] 下面我有我的代码,但我不知道我的错误点在哪里。 当我创buildJson序列化值和子部分不正确 int sheetname = 0; class Position { public Position() { this.Children = new List<Position>(); } public string Code { get; set; } public string Title { get; set; } public string Value { get; set; } public […]

在asp.net中导出为ex​​cel的date问题

protected void ExportToExcel(object sender, EventArgs e) { Response.ClearContent(); Response.AddHeader("content-disposition", "attachment;filename=Detail.xls"); Response.ContentType = "application/excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htm = new HtmlTextWriter(sw); Repeater repAllUsers = this.rptrRegistrationReport; repAllUsers.DataSource = objAdmin.Getregdetails(start, enddate, usrtype); repAllUsers.DataBind(); repAllUsers.RenderControl(htm); Response.Write("<Table border='1'" + "cellSpacing='0' cellPadding='0' " +"style='font-size:12.0pt; '>"); Response.Write(sw.ToString()); Response.End(); } 所有的数据都输出正确,但只有date栏显示#####如何在Excel文件中显示date。

无法正确使用office interop删除excel中的行

//我试图删除一些在Excel中的行。 但是我面临的问题是它并没有删除所有的logging,删除了一些行并留下了剩余的行。 for (int i = 2; i <= lastRow; i++) { Array MyValues = (Array)MySheet.get_Range("A" + i.ToString(), "AN" + i.ToString()).Cells.Value; if (Convert.ToString(MyValues.GetValue(1, 1)) == "" && Convert.ToString(MyValues.GetValue(1, 2)) == "" && Convert.ToString(MyValues.GetValue(1, 3)) == "") { break; } else { Excel.Range cells = MySheet.get_Range("A" + i.ToString(), "AN" + i.ToString()); cells.Delete(); } }

从Azure下载的Excel文件格式不正确

我正在构build一个ASP.NET WebForms应用程序,我遇到一个问题,我不知道是什么导致它。 我正在使用NPOI C#库生成Excel(.xls)文件,并且本地一切正常,但是我在Azure上托pipe了该项目,并且在下载电子表格时,它不是自动生成的,列太薄细胞内容。 我有一个从ajax请求调用的端点。 它生成的电子表格返回一个字节数组,在客户端我处理用户将如何下载它。 success: function(data) { var arr = data.d; var byteArray = new Uint8Array(arr); var a = window.document.createElement('a'); a.href = window.URL.createObjectURL(new Blob([byteArray], { type: 'application/vnd.ms-excel' })); a.download = 'myspreasheet'; // Append anchor to body. document.body.appendChild(a); a.click(); // Remove anchor from body document.body.removeChild(a); } 自动化列的NPOI方法很简单: sheet.AutoSizeColumn(0); sheet.AutoSizeColumn(1); …. 所以,我不认为这是措施文化或类似的问题。

GetChartImageUrl从Excel服务Sharepoint错误

我是新的与SharePoint的Excel服务的初学者。 我创build了一个包含数据和图表的Excel文件,然后将其上传到服务器上的Sharepoint Excel Service中,并将其更改为冗长。 我总是遇到一个问题< 当这个语句执行var s = response.GetResponseStream()时exception。 当我尝试下载从Excel服务与Excel代码C#.Net的Excel文件的图像图表这里是我的代码:[Image Source] [1] protected void btnGetImage_OnClick(object sender, EventArgs e) { _svc.Credentials = CredentialCache.DefaultCredentials; _sessopnid = _svc.OpenWorkbook(path, "", "", out _status); var chartName = "ChartOne";// ddlChart.SelectedItem.Value; var url = _svc.GetChartImageUrl(_sessopnid, null, chartName, out _status); var fileName = "resources/img.gif"; GetImageFromUrl(url).Save(fileName); imgChart.ImageUrl = fileName; } private Image GetImageFromUrl(string url) […]

跨越jquery,asp.net和excel的问题,试图导出网格到Excel,但我不能隐藏dynamicrgPager

我试图导出网格到Excel,但我不能隐藏dynamicrgPager这是Excel导出的jQuery代码 $("#btnExport").click(function (e) { window.open('data:application/vnd.ms-excel,' + encodeURIComponent($('div[id$=Retain]').html())); e.preventDefault(); 它的作品将但不隐藏寻呼机,这是与dynamic寻呼机telerik网格: <div class="datagrid PrintArea area1 all" id="Retain"> <telerik:RadGrid ID="gvProjectType" runat="server" AllowPaging="True" AllowSorting="True" ShowStatusBar="True" AutoGenerateColumns="False" AllowMultiRowSelection="True" OnNeedDataSource="gvProjectType_NeedDataSource" ClientSettings-AllowExpandCollapse="False" ClientSettings-AllowGroupExpandCollapse="False"> <PagerStyle AlwaysVisible="true" FirstPageToolTip="الأول" LastPageToolTip="الأخير" NextPagesToolTip="التالى" NextPageToolTip="التالى" PageSizeLabelText="عدد العناصر فى الصفحة:" PrevPagesToolTip="السابق" PagerTextFormat="{4} صفحة {0} من {1} ـ العناصر من {2} إلى {3} ـ إجمالي {5} عنصر" PrevPageToolTip="السابق" NextPageText="التالى" PrevPageText="السابق" […]

读取损坏的Excel使用C#

我想打开并使用C#控制台应用程序从损坏的Excel中读取数据。我试着用这个代码: public System.Data.DataTable EXc(string path, string savedFile) { try { Missing missing = Missing.Value; Excel.Application excel = new Excel.Application(); Microsoft.Office.Interop.Excel.Workbook workbook = excel.Workbooks.Open(path, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, Microsoft.Office.Interop.Excel.XlCorruptLoad.xlRepairFile); workbook.Close(true, missing, missing); if (workbook != null) { workbook.SaveAs(savedFile, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault, missing, missing, missing, missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, missing, missing, missing, […]