首页 新闻 会员 周边

C# 导出新增合计行、加项计算公式

0
悬赏园豆:20 [待解决问题]

请大佬提供BS(后台接口)导出功能案例,实现特殊功能如下:
1、导出新增合计行
2、添加项计算公式,如:H20=J20/L20*100,修改J20项,自动修改H20项数据

< >
分享
所有回答(3)
0

换个思路,直接在合计那一行直接把公示加上去,就不需要这么复杂了吧

华临天下 | 园豆:1501 (小虾三级) | 2020-06-29 14:40

请问怎么实现把公式加上去呢?

支持(0) 反对(0) 程序员胡大圣 | 园豆:7 (初学一级) | 2020-06-29 14:50

@失败也非末日: 试试用模板导出的方式

支持(0) 反对(0) 华临天下 | 园豆:1501 (小虾三级) | 2020-06-29 17:42

@华临天下: 数据不固定

支持(0) 反对(0) 程序员胡大圣 | 园豆:7 (初学一级) | 2020-06-30 15:35

@失败也非末日: https://blog.csdn.net/qq_36802111/article/details/84997953,看看这个有没有对你有用

支持(0) 反对(0) 华临天下 | 园豆:1501 (小虾三级) | 2020-06-30 15:39

@华临天下: 好的,谢谢

支持(0) 反对(0) 程序员胡大圣 | 园豆:7 (初学一级) | 2020-06-30 15:41
0

我之前的代码,你参考一下。同理,当单元格内容发生改变,重新计算H20数据
/// <summary>
/// 当前单元格值发生改变时,改变当前单元格颜色
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dataGridView1_CurrentCellDirtyStateChanged(object sender, EventArgs e)
{

        //当前行如果是新增行直接return
        string key = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
        string sql = "select count(*) from BUSINESS_OPERATOR_LIST t where t.TID = '" + key +"'";
        if (access.selectCount(sql) == 0)
        {
            //keySet.Add(key);
            return;
        }

        //bool isa = this.dataGridView1.Rows[0].IsNewRow;

        object currentCellValue = this.dataGridView1.CurrentCell.Value == null ? "" : this.dataGridView1.CurrentCell.Value;//当前单元格值
        int currentCellColumnIndex = this.dataGridView1.CurrentCell.ColumnIndex;
        string currentRowPrimaryKey = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();//当前行主键

        

        //改变cell change后颜色
        foreach (object[] obj in List)
        {
            if (currentRowPrimaryKey.Equals(obj[0].ToString()))//锁定行
            {
                if (!obj[currentCellColumnIndex].Equals(currentCellValue))
                {
                    this.dataGridView1.CurrentCell.Style.BackColor = Color.Tomato;//值被改变
                    //keySet.Add(currentRowPrimaryKey);
                }
                else
                {
                    this.dataGridView1.CurrentCell.Style.BackColor = Color.White;//值未改变
                }
            }
        }
    }
pecool | 园豆:14 (初学一级) | 2020-06-30 09:21

谢谢啊,是bs项目

支持(0) 反对(0) 程序员胡大圣 | 园豆:7 (初学一级) | 2020-06-30 15:37
0

一种最简单的是在sql查询就使用union all 添加一行合计数就可以了

F12-爱码士 | 园豆:254 (菜鸟二级) | 2020-09-09 16:28
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册