- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我目前正在为从数据集/数据网格导出的特定 Excel 文件格式化日期。
日期格式如下:
DateTime date = Convert.ToDateTime(entry.Date);
string formatdate = String.Format("{0:yyyy/MM/dd}", date);
创建 DataSet 后,我使用以下代码将 DataSet 导出到 Excel 文件:
public static void ExportDStoExcel(DataSet ds, string filename)
{
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.Charset = "";
response.ContentType = "application/vnd.ms-excel";
response.AddHeader("Content-Disposition", "attachment;filename=\"" + filename + "\"");
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
DataGrid dg = new DataGrid();
dg.DataSource = ds.Tables[0];
dg.DataBind();
dg.RenderControl(htw);
response.Write(sw.ToString());
response.End();
}
}
}
我唯一的问题是一旦我将其导出到 Excel,Excel 会像这样自动格式化日期:MM/DD/YYYY 而不是 YYYY/MM/DD。
我知道这可以通过在 Excel 中打开来手动实现,但导出正在构建到一个自动化系统中,需要进行硬编码。
有什么方法可以绕过 Excel 的日期时间自动格式化?
最佳答案
我遇到了同样的问题,通过在文本前面添加一个不间断空格 ( ) 解决了这个问题。停止 Excel 自动格式化。不是最干净的解决方案,但对我有用......
关于c# - 在 C# 中从 DataGrid 导出到 Excel 时停止日期自动格式化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4413471/
我正在使用 Avalonia.Controls.DataGrid。默认情况下,当网格获得焦点并按下 Enter 时,它会自动处理事件并将选择移动到下一项。我怎样才能防止这种默认行为?我想要一个自定义的
根据我所见,Dojo DataGrid 中的格式化程序函数被赋予以下参数:单元格值、单元格行号和单元格对象本身。鉴于这些参数,您能否建议如何获取此单元格所引用的数据存储项?或者,如果您能提出替代方法,
我是DoJo开发的新手,所以这可能很基础。 我创建了一个EnhancedDatagrid,它可以很好地显示数据。 数据来自另一个页面中的JSON存储。 我有一个按钮,该按钮导致在数据存储中创建一个新条
我正在尝试在 WPF DataGrid 的 RowDetailsTemplate 中创建一个 DataGrid。 我有一系列工作。每个工作都可以分配一个或多个员工: public class Job
我有一个数据网格组件: [... some controlls ...]
我已经以编程方式创建了一个dojox.grid.datagrid,并且我需要对列进行自定义排序。为此,我尝试使用 ItemFileWriteStore.comparatorMap['field'] =
我试图在 UWP RadDataGrid 控件的 Telerik UI 中隐藏 GroupPanel。 radgrid.ShowGroupPanel 不起作用。 最佳答案 UserGroupMode=
我收到“在使用 ItemsSource 时操作无效。改为使用 ItemsControl.ItemsSource 访问和修改元素”错误,我不确定原因。 我正在尝试将数据网格嵌套在数据网格中。如果我只使用
我的 WPF forme Etudiant 中有一个 DataGrid 当单击 Etudiant 中名为 Epreuve 的行时,我需要显示其他数据网格,并且当在 Epreuve 中选择一行并且我需要
我有一个 DataGrid“嵌套”在另一个 DataGrid 的 RowDetailsTemplate 中。只要我的鼠标悬停在父 DataGrid 上行的主要部分上,滚动就可以正常工作,但是当鼠标悬停
我花了几个小时看这个没有结果。 我只是想要一个DataGrid X 列保持与 Grid 的相对宽度本身。 因此,例如: 第 1 栏:10% 第 2 栏:10% 第 3 栏:10% 我设置了一个附加到
我有 3 个共享相同数据类型的数据网格。我想配置一次列绑定(bind)并让 3 个数据网格共享资源。 例如
我之前关于检测 VM 中的属性更改的帖子不够深入,所以我发布了这个 我有一个工作网格。每个工作可以有一个或多个员工。 DataGrid 的 RowDetailsTemplate 包含另一个用于显示员工
我将尝试找出将 ComboBox 嵌入到 Flex (3.4) DataGrid 中的“正确”方法。根据权利(例如,根据本页 http://blog.flexmonkeypatches.com/200
我有一个对象集合,我们称之为 People,每个对象都由名称、ID 和时间字符串组成。这些人物必须显示在类似于固定行数和 9 列的网格上。这个想法是将人员作为行添加到第 1、2 和 3 列中的网格左侧
默认行为是使用 CTRL+Click 取消选择 Datagrid 中的项目 我希望能够通过鼠标单击(左键或右键)网格中的空白区域并让它取消选择任何选定的项目。 我已经用谷歌搜索死了,发现了一些非常复杂
我正在使用 DataGrid来自 WPF Toolkit我需要能够将注意力集中在网格的底部(即最后一行)。我现在遇到的问题是,随着行的添加,DataGrid 的滚动条不会随着新行的添加而滚动。实现此目
我正在使用 DataGrid 来管理服务配置。我想使用自动生成的行复选框来管理多个删除操作,但想使用 onRowClick 事件将行数据提供给模态对话框表单进行编辑。我的 onRowClick 处理程
我有一个包含项目的 DataGrid。当您右键单击其中一行时,会显示一个 Dojo 上下文菜单,其中包含删除该行的选项。如果您尝试右键单击 DataGrid 的空白区域,则不会显示上下文菜单……但是,
我想在另一个 Datagrid 的 RowDetailsTempalte 中使用一个 DataGrid。此内部 Datagrid 应将其列绑定(bind)到外部 Datagrid 中当前对象的属性。例
我是一名优秀的程序员,十分优秀!