小编Chi*_*ome的帖子

C# NPOI 将单元格样式设置为文本/字符串 1-19 格式化为日期/禁用任何格式

我正在创建一个Excel,当我编写一些值示例1-19时,当我打开Excel文档时,我看到1-19,但是如果我单击它,那么Excel会尝试将其格式化为日期

有没有办法强制工作表不使用任何公式或格式?我查了一下,数据格式是字符串。

 private void Test1(ref ISheet worksheet, string[] array, IWorkbook workbook, int iRow, XSSFFont font2)
        {
            var format = HSSFDataFormat.GetBuiltinFormats();

            ICellStyle _TextCellStyle = workbook.CreateCellStyle();
            _TextCellStyle.DataFormat = workbook.CreateDataFormat().GetFormat("@");
            IRow file = worksheet.CreateRow(iRow);
            int iCol = 0;
            for (int y = 0; y < array.Length; y++)
            {
                ICellStyle style = workbook.CreateCellStyle();

                style.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Grey25Percent.Index;
                //style.DataFormat = HSSFDataFormat.
                ICell cell = file.CreateCell(iCol, CellType.String);
                cell.SetCellValue(array[y]);
                style.SetFont(font2);
               // cell.CellStyle = style;
                var getst = cell.CellType;
                cell.CellStyle = _TextCellStyle;
                iCol++;
                getst = cell.CellType;

            }

        }
Run Code Online (Sandbox Code Playgroud)

excel npoi c#-4.0

4
推荐指数
1
解决办法
6642
查看次数

使用LINQ和GridView

我是网络开发新手并使用控件,所以请原谅我.

我有一个带有复选框的GridView(请参阅下面的标记)

当用户通过并检查任何框并点击我的提交按钮时,我想运行LINQ查询以获取具有checkbox1.checked = True的所有行

就像是:

Dim sList = (From row in Gridview1
             Where row.Cells("IsStarFleet") = True
             row.Cells("ID)).ToList
Run Code Online (Sandbox Code Playgroud)

标记:

<asp:GridView ID="GridView1" runat="server" Width="516px" AutoGenerateColumns="False" AllowPaging="True">
    <Columns>
        <asp:BoundField DataField="ID" HeaderText="ID" />
        <asp:BoundField DataField="FirstName" HeaderText="FirstName" />
        <asp:TemplateField HeaderText="IsStarFleet">
            <ItemTemplate>
                <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack ="False" />
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
Run Code Online (Sandbox Code Playgroud)

linq vb.net asp.net checkbox gridview

0
推荐指数
1
解决办法
2649
查看次数

标签 统计

asp.net ×1

c#-4.0 ×1

checkbox ×1

excel ×1

gridview ×1

linq ×1

npoi ×1

vb.net ×1