我想在一个值中插入一个值,其中Person ='John'列标题为'Oct-14'
包含'Oct-14'的顶级单元格是两个单元格的合并,下面是包含'Points'和'Days'的单个单元格。
OleDbCommand cmd1 = new OleDbCommand("Update [Sheet1$] "+
"set [Points] = ‘Value ’ where [Person]='John' AND ? = ‘Oct-14’ ", cn);
--------------------------------------------------------- | | Oct-14 | Nov-14 | --------------------------------------------------------- |Person | Points | Days | Points | Days | --------------------------------------------------------- |John | 'Value' | | | | --------------------------------------------------------- |Jodie | | | | | --------------------------------------------------------- |Alex | | | | | ---------------------------------------------------------
答案 0 :(得分:1)
默认情况下,当您合并单元格时,它会将数据输入到第一个单元格中。移动"人"到第一行并添加HDR = YES;。
OleDbCommand cmd1 = new OleDbCommand("Update [Sheet1$] "+
"set [Oct-14] = ‘Value ’ where [Person]='John', cn);
如果仅在使用Oct-14时出现问题,请尝试将其转换为OLE自动化日期。
var DateToCheck = (int) DateTime.Parse(DateTime.Now.ToString("01/11/2014"),
new CultureInfo("en-GB")).ToOADate();