本文整理汇总了C#中Table.Cell方法的典型用法代码示例。如果您正苦于以下问题:C# Table.Cell方法的具体用法?C# Table.Cell怎么用?C# Table.Cell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Table
的用法示例。
在下文中一共展示了Table.Cell方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: calculateSum
private int calculateSum(int i, int j, Table table, int col, DataGridView dataView, int tableLine) //一个主项递归计算(部分递归,效率提高)计算第i行j列主项的第col列值,在显示表中是第tableLine行
{
int itemRow = i;
int itemColumn = j;
int count = 0;//第几个子项(2类)
i++;
j++;
Decimal sum = 0;
while (true) //循环计算主项里面的值
{
int newLine = 0;
Decimal value = getNormalValue(i, j + col, table);
sum += value;
int isMItem = isMainItem(i, j, table);
if (isMItem == 2) //遇到子项是主项则计算主项并返回newLine
{
count++;
newLine = calculateSum(i, j, table, col, dataView, count + tableLine);
i = newLine;
}
else //如果子项不是主项情况2则行数递增1,继续计算
{
i++;
}
Match m = over.Match(table.Cell(i, j - 1).Range.Text);
if (m.Length == 0)//如果当前主项计算完毕,打印计算值,并返回新的计算行(左边单元格匹配不到大写字母)
{
if (value != -1)
{
// System.Diagnostics.Debug.WriteLine(sum + " ssss");
System.Diagnostics.Debug.WriteLine(tableLine + " dddd " + sum);
lineInfo.Add(tableLine);
addViewItem(tableLine, col, dataView, table, itemRow, itemColumn, sum);
calValue.Add(sum);
addValueItem(itemRow, itemColumn, table, col);
}
else
{
}
if (i == table.Rows.Count)//遍历到最低端
{
flag = true;//结束完一轮计算
return table.Rows.Count;
}
return i;
}
}
}
示例2: calColumn
private int calColumn(Table table, int i, int j)//计算有几列值需要被计算
{
int columns = 0;
while (true)
{
try
{
j++;
Cell cell = table.Cell(i, j);
columns++;
}
catch
{
return columns;
}
}
}
示例3: getStartLocation
private int[] getStartLocation(Table table)
{
int[] location = new int[2];
int rows = table.Rows.Count;
int columns = table.Columns.Count;
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= columns; j++)
{
try
{
string cell = table.Cell(i, j).Range.Text;
Match m = regex.Match(cell);
if (m.Length != 0)//匹配到第一个大写字母则终止查询
{
location[0] = i;
location[1] = j + 1;
return location;
}
}
catch
{
}
}
}
return location;
}
示例4: getNormalCell
/*private void addMItems(int i, int j, Table table, List<string> itemNames)
{
string item = table.Cell(i, j).Range.Text;
item = getNormalCell(item);
if (itemNames.Count == 0)
{
itemNames.Add(item);
}
else if (!itemNames[itemNames.Count - 1].Equals(item))
{
itemNames.Add(item);
}
}*/
private void addSubItems(int i, int j, Table table, Dictionary<string, string> itemNames)
{
string value = table.Cell(i, j).Range.Text;
string key = table.Cell(i, j - 1).Range.Text;
key = getNormalCell(key);
value = getNormalCell(value);
itemNames.Add(key, value);
}
示例5: addMItems
private void addMItems(int i, int j, Table table, Dictionary<string, string> keyItem)
{
string value = table.Cell(i, j).Range.Text;
string key = table.Cell(i, j - 1).Range.Text;
key = getNormalCell(key);
value = getNormalCell(value);
if (keyItem.Count == 0)
{
keyItem.Add(key, value);
}
else if (!keyItem.Values.Last().Equals(value))
{
keyItem.Add(key, value);
}
}
示例6: addValueItem
private void addValueItem(int i, int j, Table table, int col)
{
if (flag == false)
{
string item = table.Cell(i, j).Range.Text;
item = getNormalCell(item);
itemName.Add(item);
}
Decimal value = getNormalValue(i, j + col, table);
originalValue.Add(value);
}
示例7: convertTable
private static Dictionary<string, ArrayList> convertTable(Table table)
{
if (table.Columns.Count < 2)
{
throw new ArgumentException("Table must contain more then 1 column to be legal data source");
}
int transalationsCount = table.Columns.Count / 2;
Dictionary<string, ArrayList> dictionary = new Dictionary<string, ArrayList>(StringComparer.InvariantCultureIgnoreCase);
for (int i = 1; i <= table.Rows.Count; ++i)
{
for (int j = 1; j <= transalationsCount; j += 2)
{
string acronym = cleanCellText(table.Cell(i, j).Range.Text);
string translation = cleanCellText(table.Cell(i, j + 1).Range.Text);
if (!dictionary.ContainsKey(acronym))
{
dictionary.Add(acronym, new ArrayList(new string[] { translation }));
}
else
{
dictionary[acronym].Add(translation);
}
}
}
return dictionary;
}
示例8: GetAndPutDowSchedule
private static Table GetAndPutDowSchedule(ScheduleRepository repo, int lessonLength, int dayOfWeek, bool weekFiltered, int weekFilter, bool weeksMarksVisible, Faculty faculty, _Document oDoc, object oEndOfDoc, _Application oWord, Table tableToContinue, CancellationToken cToken)
{
cToken.ThrowIfCancellationRequested();
var schedule = repo.Lessons.GetFacultyDowSchedule(faculty.FacultyId, dayOfWeek, weekFiltered, weekFilter, false, false);
cToken.ThrowIfCancellationRequested();
var timeList = new List<string>();
foreach (var group in schedule)
{
foreach (var time in @group.Value.Keys)
{
if (!timeList.Contains(time))
{
timeList.Add(time);
}
}
}
Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
Table oTable;
var tableRowOffset = 0;
if (tableToContinue == null)
{
oTable = oDoc.Tables.Add(wrdRng, 1 + timeList.Count, 1 + schedule.Count);
oTable.Borders.Enable = 1;
oTable.Range.ParagraphFormat.SpaceAfter = 0.0F;
oTable.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphLeft;
oTable.Range.Font.Size = 10;
oTable.Range.Font.Bold = 0;
oTable.Columns[1].Width = oWord.CentimetersToPoints(2.44f);
float colWidth = 25.64F / schedule.Count;
for (int i = 0; i < schedule.Count; i++)
{
oTable.Columns[i + 2].Width = oWord.CentimetersToPoints(colWidth);
}
}
else
{
oTable = tableToContinue;
tableRowOffset = oTable.Rows.Count;
for (int i = 0; i < 1 + timeList.Count; i++)
{
oTable.Rows.Add();
for (int j = 1; j <= 1 + schedule.Count; j++)
{
oTable.Cell(tableRowOffset + i + 1, j).Borders[WdBorderType.wdBorderDiagonalUp].Visible = false;
}
}
}
oTable.Cell(tableRowOffset + 1, 1).Range.Text = Constants.DowLocal[dayOfWeek];
oTable.Cell(tableRowOffset + 1, 1).Range.Bold = 1;
oTable.Cell(tableRowOffset + 1, 1).Range.ParagraphFormat.Alignment =
WdParagraphAlignment.wdAlignParagraphCenter;
int groupColumn = 2;
foreach (var group in schedule)
{
var groupObject = repo.StudentGroups.GetStudentGroup(@group.Key);
var groupName = groupObject.Name;
oTable.Cell(tableRowOffset + 1, groupColumn).Range.Text = groupName;
oTable.Cell(tableRowOffset + 1, groupColumn).Range.Bold = 1;
oTable.Cell(tableRowOffset + 1, groupColumn).Range.ParagraphFormat.Alignment =
WdParagraphAlignment.wdAlignParagraphCenter;
groupColumn++;
}
var timeRowIndexList = new List<int>();
var timeRowIndex = 2;
foreach (var time in timeList.OrderBy(t => int.Parse(t.Split(':')[0]) * 60 + int.Parse(t.Split(':')[1])))
{
cToken.ThrowIfCancellationRequested();
var hour = int.Parse(time.Substring(0, 2));
var minute = int.Parse(time.Substring(3, 2));
minute += lessonLength;
while (minute >= 60)
{
hour++;
minute -= 60;
}
timeRowIndexList.Add(timeRowIndex);
oTable.Cell(tableRowOffset + timeRowIndex, 1).Range.Text = time + " - " +
hour.ToString("D2") + ":" + minute.ToString("D2");
oTable.Cell(tableRowOffset + timeRowIndex, 1).Range.Bold = 1;
oTable.Cell(tableRowOffset + timeRowIndex, 1).Range.ParagraphFormat.Alignment =
WdParagraphAlignment.wdAlignParagraphCenter;
//.........这里部分代码省略.........
示例9: getItems
private int getItems(int i, int j, Table table, Dictionary<string, string> keyItem) //一个主项递归计算(部分递归,效率提高)
{
addMItems(i, j, table, keyItem);
i++;
j++;
while (true) //循环计算主项里面的值
{
int newLine = 0;
addSubItems(i, j, table, keyItem);
int isMItem = isMainItem(i, j, table);
if (isMItem == 2) //遇到子项是主项则计算主项并返回newLine
{
newLine = getItems(i, j, table, keyItem);
i = newLine;
}
else //如果子项不是主项情况2则行数递增1,继续计算
{
i++;
}
if (i > table.Rows.Count) //如果行数大于表行则终止递归,输出sum
{
return i - 1;
}
Match m = over.Match(table.Cell(i, j - 1).Range.Text);
if (m.Length == 0)//如果当前主项计算完毕,打印计算值,并返回新的计算行(左边单元格匹配不到大写字母)
{
if (i == table.Rows.Count)//遍历到最低端
{
return table.Rows.Count;
}
return i;
}
}
}
示例10: compareTables
private string compareTables(Table regTable, Table testTable, string targetTableName)
{
int regColumns = regTable.Columns.Count;
int regRows = regTable.Rows.Count;
int testColumns = testTable.Columns.Count;
int testRows = testTable.Rows.Count;
Cell regCell, testCell;
String compareResult = "";
if (regColumns == testColumns && regRows == testRows)
{
for (int i = 1; i <= regRows; i++)
{
for (int j = 1; j <= regColumns; j++)
{
try //如果规程文档表格当前单元格存在,则目标文档相应表格单元格也应存在且内容相等
{
regCell = regTable.Cell(i, j);
try
{
testCell = testTable.Cell(i, j);
if (!regCell.Range.Text.Equals(//目标文档相应单元格存在,如果单元格内容不相同,则内容不一致
testCell.Range.Text))
{
//MessageBox.Show(i+"×"+j+"单元格内容不一致");
compareResult = targetTableName + i + "×" + j + "单元格内容不一致";
return compareResult;
}
}
catch //目标文档相应表格单元格不存在
{
//MessageBox.Show("模式不对1:目标文档相应表格单元格不存在");
compareResult = targetTableName + ":目标文档相应表格单元格缺失";
return compareResult;
}
}
catch //如果规程文档表格当前单元格不存在,目标文档相应单元格也须不存在
{
try
{
testCell = testTable.Cell(i, j);//如果目标文档相应单元格存在则报错
//MessageBox.Show("模式不对2:规程文档目标文档单元格不匹配");
compareResult = targetTableName + ":规程文档目标文档某单元格不匹配";
return compareResult;
}
catch //目标文档相应表格单元格不存在
{
continue;
}
}
}
}
}
else
{
//MessageBox.Show("模式不对3");
compareResult = targetTableName + ":目标文档表格行列数有误";
return compareResult;
}
return "正确";
}
示例11: getNormalCell
/*private void addMItems(int i, int j, Table table, List<string> itemNames)
{
string item = table.Cell(i, j).Range.Text;
item = getNormalCell(item);
if (itemNames.Count == 0)
{
itemNames.Add(item);
}
else if (!itemNames[itemNames.Count - 1].Equals(item))
{
itemNames.Add(item);
}
}*/
private void addSubItems(int i, int j, Table table, Dictionary<string, string> itemNames)
{
int cl = j-1;
if (colNum == 2) cl = j + 1;
string value = table.Cell(i, j).Range.Text;
string key = table.Cell(i, cl).Range.Text;
key = getNormalCell(key);
value = getNormalCell(value);
try
{
itemNames.Add(key, value);
}
catch { };
}
示例12: getTableCellText
private string getTableCellText(Table table,int row, int column)
{
string text = table.Cell(row, column).Range.Text;
text = delimiterEnterChar(text);
return text;
}
示例13: getTableCellContainer
private TermContainer getTableCellContainer(string section,Table table, int row)
{
string name = table.Cell(row, 2).Range.Text;
string tip = table.Cell(row, 3).Range.Text;
name = delimiterEnterChar(name);
tip = delimiterEnterChar(tip);
return new TermContainer(section,name, tip);
}
示例14: SetDefaultTableHeader
protected virtual void SetDefaultTableHeader(Table table, int columnCount, int headerStart = 1)
{
for (int i = 0; i < columnCount; i++)
{
table.Cell(headerStart, i + 1).Range.Bold = 2;
table.Cell(headerStart, i + 1).Select();
table.Cell(headerStart, i + 1).VerticalAlignment = WdCellVerticalAlignment.wdCellAlignVerticalCenter; //垂直居中
table.Cell(headerStart, i + 1).Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
}
}
示例15: FillData
public void FillData(Table table)
{
int j = 2;
foreach (TestData data in TestData.GetTestDatas())
{
table.Cell(j, 1).Range.Text = data.ID.ToString(CultureInfo.InvariantCulture);
table.Cell(j, 2).Range.Text = data.Name;
table.Cell(j, 3).Range.Text = data.ID.ToString(CultureInfo.InvariantCulture);
table.Cell(j, 4).Range.Text = data.Name;
table.Cell(j, 5).Range.Text = data.ID.ToString(CultureInfo.InvariantCulture);
j++;
}
}