Excel表格网

grid导出excel前台导出(gridcontrol导出excel)

134 2022-10-08 09:30 万梦   手机版

1. gridcontrol导出excel

1、Access中新建数据库,名字为Database1.mdb。(注意:后缀为MDB,如果Access是2007版本的,保存时应另存为03版本的才可以,因为,VB无法直接支持07版的accdb后缀格式)



2、成功建立数据库后会进入到数据表界面,这时就能输入数据了,输完以后按CTRL+S保存,输入表名,这里表名为test,准备工作这样就完成了。



3、把VB打开,然后新建标准exe。



4、在菜单里面找到工程→部件→勾选 ,Microsoft ADO Data Control 6.0 Microsoft Hierarchical Flexgrid Control 6.0勾选之后左侧的工具栏里就多出两个控件,就是 ADODC控件和MSHFlexGrid控件。



5、选择 ADODC控件和MSHFlexGrid控件,在窗体的合适位置放入,如图:



6、设置ADODC控件的属性:右键窗体中ADODC1控件

ADODC属性页→通用→选择使用连接字符串→点击生成→选择Microsoft Jet 4.0 OLE DB Provider 点击下一步→选择之前准备好的数据库→点击测试连接,显示测试成功则ok,确定。

ADODC属性页→记录源→命令类型选择2-adcmdtable,表或存储过程名称选择之前建立的数据表test,点击确定,ADODC属性设置完成。







7、设置MSHFlexGrid控件的属性:VB右侧的属性表里,找到datasource,选择adodc1。



8、测试效果:菜单→运行→启动(F5),发现显示的数据排列不是我们想要的行数和列数修改方法:

MSHFlexGrid属性→通用→设置行和列,固定行和固定列,设置如图。

MSHFlexGrid属性→带区→把列标题的√取消掉,设置如图。





9、修改之后测试效果如下:



2. gridcontrol导出Excel没有颜色

数据组件也可称为数据显示组件或数据浏览组件。它们的主要功能是和数据访问组件配合,供用户对数据进行浏览、编辑等操作。

数据控制组件在组件板上的Data Control 页上,共有15 个组件。它们分别是DBGrid组件,DBNavigator组件,DBText组件,DBEdin 组件,DBMemo 组件,DBlmage 组件,DBLisbox 组件,DBComboBx 组件,DBCheckBox 组件,DBRadioGroup 组件,DBLookupListBox 组件,DBLookupComboBox 组件,DBRichEdit 组件,DBCrlGrd组件和DBChart 组件。这些组件类似于VFP中的基类控件,用于实现数据的交互和展现,如需要用户输入的数据,采用Edit 组件;需要用户选择的数据,采用ComboBox组件;显示多条数据记录,采用DbGrid组件。


3. gridcontrol导出界面数据到excel

这个问题一般是由跨线程操作UI引起的,以前 DevExpress 的官方文档里专门有这个问题,我刚才找了下新版本的,没找到。不过你用谷歌或者必应搜索:xtragrid big red-cross 会有很多相似问题,答案基本都是因为跨线程操作引起的。一般来说可视的控件里只有三个方法是线程安全的:CreateGraphics、BeginInvoke 和 Invoke。其他情况,需要自己确保线程安全。


4. gridcontrol导出pdf

VB中表格控件有很多,如MSFlexGrid,DataGrid,MSHFlexGrid等等使用的多的是微软的FlexGrid控件。通过菜单"Project" -> "Components" -> 勾上"Microsoft FlexGrid Control 6.0"进行选择。这个是包含在VS6 SP6安装包内的。


5. gridcontrol导出excel怎么把筛选去掉

我的一个GridView操作文件,数据源是实体LIST,删改查功能都有了,你参考下 using System; using System.Collections; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using lwf_MVC.CTRL; using lwf_MVC.lwf_Normal; using lwf_MVC.MODEL; public partial class admin_news_edit : System.Web.UI.Page { public string icls_name = "cls_f_news"; //不同级数系列区别在于iWhere public string iWhere = " 1 = 1 and ENG = " + WEB.GQ("ENG", "0") + " and TID1 = " + WEB.GQ("SSS", "1") + " and 1 = 1"; public int getRecordCount() { cls_f_news if_news = (cls_f_news)CTRL.CreateModel(icls_name); if_news.title = soKey.Text; if_news.contents = soKey.Text; if_news.WHERE = iWhere; int i_recordcount = CTRL.getCount(if_news, "order by orderid,id desc"); return i_recordcount; } protected void Page_Load(object sender, EventArgs e) { if (WEB.getSession("userName") == null || WEB.getSession("userName") == "") JS.RD(System.Web.HttpUtility.UrlDecode("%e7%99%bb%e9%99%86%e8%b6%85%e6%97%b6%2c%e8%af%b7%e9%87%8d%e6%96%b0%e7%99%bb").Trim(), "../login.aspx"); if (!IsPostBack) { AspNetPagerBin(1); GridViewBin(); } } protected void AspNetPagerBin(int curr) { int i_recordcount = getRecordCount(); AspNetPager1.RecordCount = i_recordcount; AspNetPager1.CurrentPageIndex = curr; } protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { GridView1.EditIndex = e.NewEditIndex; GridViewBin(); } protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { GridView1.EditIndex = -1; GridViewBin(); } protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { int i_id = int.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString()); cls_f_news baseTableObj = (cls_f_news)CTRL.CreateModel(icls_name, i_id); baseTableObj.title = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text.ToString(); baseTableObj.newfrom = ((TextBox)GridView1.Rows[e.RowIndex].Cells[3].Controls[0]).Text.ToString(); baseTableObj.addTime = DateTime.Parse(((TextBox)GridView1.Rows[e.RowIndex].Cells[4].Controls[0]).Text.ToString()); baseTableObj.orderid = int.Parse(((TextBox)GridView1.Rows[e.RowIndex].FindControl("tb_orderid_b")).Text.ToString()); if (CTRL.Update(baseTableObj)) { JS.alert(System.Web.HttpUtility.UrlDecode("%e4%bf%ae%e6%94%b9%e6%88%90%e5%8a%9f").Trim()); } else { JS.alert(System.Web.HttpUtility.UrlDecode("%e7%bd%91%e7%bb%9c%e8%b6%85%e6%97%b6%ef%bc%8c%e8%af%b7%e9%87%8d%e6%96%b0%e5%86%8d%e8%af%95").Trim()); } //==================================== GridView1.EditIndex = -1; GridViewBin(); } protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int i_id = int.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString()); cls_f_news baseTableObj = (cls_f_news)CTRL.CreateModel(icls_name, i_id); if (CTRL.Delete(baseTableObj)) { JS.alert(System.Web.HttpUtility.UrlDecode("%e8%ae%b0%e5%bd%95%e5%88%a0%e9%99%a4%e6%88%90%e5%8a%9f").Trim()); } else { JS.alert(System.Web.HttpUtility.UrlDecode("%e7%bd%91%e7%bb%9c%e8%b6%85%e6%97%b6%ef%bc%8c%e8%af%b7%e9%87%8d%e6%96%b0%e5%86%8d%e8%af%95").Trim()); } //==================================== GridView1.EditIndex = -1; GridViewBin(); } protected void AspNetPager1_PageChanged(object sender, EventArgs e) { GridView1.EditIndex = -1; GridView1.PageIndex = AspNetPager1.CurrentPageIndex; GridViewBin(); } protected void CheckBox_all_CheckedChanged(object sender, EventArgs e) { CheckBox_opp.Checked = false; for (int i_i = 0; i_i <= GridView1.Rows.Count - 1; i_i++) { CheckBox ckb = (CheckBox)GridView1.Rows[i_i].FindControl("cb_selBoxs"); if (CheckBox_all.Checked) { ckb.Checked = true; } else { ckb.Checked = false; } } } protected void CheckBox_opp_CheckedChanged(object sender, EventArgs e) { CheckBox_all.Checked = false; for (int i_i = 0; i_i <= GridView1.Rows.Count - 1; i_i++) { CheckBox ckb = (CheckBox)GridView1.Rows[i_i].FindControl("cb_selBoxs"); if (ckb.Checked) { ckb.Checked = false; } else { ckb.Checked = true; } } } protected void lb_delete_Click(object sender, EventArgs e) { for (int i_i = 0; i_i <= GridView1.Rows.Count - 1; i_i++) { CheckBox ckb = (CheckBox)GridView1.Rows[i_i].FindControl("cb_selBoxs"); if (ckb.Checked) { int i_id = int.Parse(GridView1.DataKeys[i_i].Value.ToString()); cls_f_news baseTableObj = (cls_f_news)CTRL.CreateModel(icls_name, i_id); CTRL.Delete(baseTableObj); } } int i_Pcount = getRecordCount(); if (AspNetPager1.CurrentPageIndex > i_Pcount) { AspNetPagerBin(i_Pcount); } else { AspNetPagerBin(AspNetPager1.CurrentPageIndex); } GridViewBin(); } protected void lb_order_Click(object sender, EventArgs e) { for (int i_i = 0; i_i <= GridView1.Rows.Count - 1; i_i++) { TextBox tb = (TextBox)GridView1.Rows[i_i].FindControl("tb_orderid_a"); int i_id = int.Parse(GridView1.DataKeys[i_i].Value.ToString()); cls_f_news baseTableObj = (cls_f_news)CTRL.CreateModel(icls_name, i_id); baseTableObj.orderid = int.Parse(tb.Text.ToString()); CTRL.Update(baseTableObj); } GridViewBin(); } protected void bt_search_Click(object sender, EventArgs e) { AspNetPagerBin(1); GridViewBin(); } protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { int rowNum; int id_i; } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { } } protected void GridView1_Sorting(object sender, GridViewSortEventArgs e) { string sortExpression = e.SortExpression; ViewState["sortExpression"] = sortExpression; if (ViewState["ASC"].ToString() == "0") { ViewState["ASC"] = "1"; } else { ViewState["ASC"] = "0"; } AspNetPagerBin(1); GridViewBin(); } protected void GridViewBin() { CheckBox_all.Checked = false; cls_f_news if_news = (cls_f_news)CTRL.CreateModel(icls_name); if_news.title = soKey.Text; if_news.contents = soKey.Text; if_news.WHERE = iWhere; int RecordCount; int curP = Convert.ToInt32(AspNetPager1.CurrentPageIndex); List<cls_f_news> iList_f_news = CTRL.getPageList(if_news, "order by orderid,id desc", AspNetPager1.PageSize, curP, out RecordCount).ConvertAll<cls_f_news>(delegate(lwf_MVC.MODEL.baseTable s) { return (cls_f_news)s; }); if (ViewState["ASC"] == null) ViewState["ASC"] = "-1"; if (ViewState["sortExpression"] == null) ViewState["sortExpression"] = "orderid"; if (ViewState["ASC"].ToString() == "-1") { iList_f_news.Sort(delegate(cls_f_news a, cls_f_news b) { return (new CaseInsensitiveComparer()).Compare(a.GetType().GetProperty(ViewState["sortExpression"].ToString()).GetValue(a, null), b.GetType().GetProperty(ViewState["sortExpression"].ToString()).GetValue(b, null)); }); } else { if (ViewState["ASC"].ToString() == "1") { iList_f_news.Sort(delegate(cls_f_news a, cls_f_news b) { return (new CaseInsensitiveComparer()).Compare(a.GetType().GetProperty(ViewState["sortExpression"].ToString()).GetValue(a, null), b.GetType().GetProperty(ViewState["sortExpression"].ToString()).GetValue(b, null)); }); } else { iList_f_news.Sort(delegate(cls_f_news a, cls_f_news b) { return (new CaseInsensitiveComparer()).Compare(b.GetType().GetProperty(ViewState["sortExpression"].ToString()).GetValue(b, null), a.GetType().GetProperty(ViewState["sortExpression"].ToString()).GetValue(a, null)); }); } } GridView1.DataSource = iList_f_news; GridView1.DataKeyNames = new string[] { "id" }; GridView1.DataBind(); } }


6. gridcontrol导出数据到Excel指定sheet中

主界面->options->sheet properties->workspace->show grid这一项把勾去掉


7. gridcontrol导出后删除第一列

//声明ColumnView对象 var columnView = (ColumnView)gridControl1 .FocusedView; //得到选中的行索引 int focusedhandle = columnView.FocusedRowHandle;


8. gridcontrol导出excel 去除表格线

DEV全称是:Developer Express 是一个第三方控件包,gridcontrlo是里面的其中一个控件,网格控件,相对于微软自带的那个功能强大的多!全球使用最多的,是美国的,收费的,不交钱也可以用,但会有提示,用于开发WIN FROM程序很给力,我现在就用的它!


9. gridcontrol导出excel 去除样式

为了更好地面向国家重大需求,瞄准学科发展前沿,同时有效继承课题组的传统,课题组于2011年正式更名为智能电网运行与控制课题组,英文全称为Smart Grid Operation & Control Group,简称SGO(思构)课题组。“思构”既是课题组的简称,同时也是课题组提倡的行为准则:思行合一,思考以确定目标,行动以实现目标。


顶一下
(0)
0%
踩一下
(0)
0%
相关评论
我要评论
用户名: 验证码:点击我更换图片