设置列标题提示

可能的使用场景

在工作表中创建表格时,您可能需要为自定义列设置工具提示。Aspose.Cells.GridWeb允许您重命名列标题并为列设置工具提示,这样用户就可以轻松理解列的作用。

设置列标题提示

下面是一个完整的示例,演示如何更改列标题和应用工具提示文本。执行以上示例代码后,当您将鼠标光标放在指定列的标题上时,工具提示文本将弹出,如下所示。

todo:image_alt_text

示例代码

以下是ASPX页面的示例脚本。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
<form id="form1" runat="server">
<div>
<acw:GridWeb ID="GridWeb1" runat="server" XhtmlMode="True" Height="350px" Width="700px">
</acw:GridWeb>
</div>
</form>

以下是ASPX Code Behind CS文件的示例代码。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Access the first worksheet
GridWorksheet gridSheet = GridWeb1.WorkSheets[0];
//Input data into the cells of the first worksheet.
gridSheet.Cells["A1"].PutValue("Product1");
gridSheet.Cells["A2"].PutValue("Product2");
gridSheet.Cells["A3"].PutValue("Product3");
gridSheet.Cells["A4"].PutValue("Product4");
gridSheet.Cells["B1"].PutValue(100);
gridSheet.Cells["B2"].PutValue(200);
gridSheet.Cells["B3"].PutValue(300);
gridSheet.Cells["B4"].PutValue(400);
//Set the caption of the first two columns.
gridSheet.SetColumnCaption(0, "Product Name");
gridSheet.SetColumnCaption(1, "Price");
//Set the column width of the first column.
gridSheet.Cells.SetColumnWidth(0, 20);
//Set the second column header's tip.
gridSheet.SetColumnHeaderToolTip(1, "Unit Price of Products");