0
xlsx要素を読み込み、すべての要素が印刷されるまで4行4列ずつ印刷したいが、ファイルのすべての要素を印刷するので問題がある。どのようにそれらを印刷するか4C#でxlsxファイルを読む
// Open the Excel file.
Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(Path.GetFullPath(@"C:\Users\user\Documents\Book2.xlsx"));
// Get the first worksheet.
Excel.Worksheet xlWorksheet = (Excel.Worksheet)xlWorkbook.Sheets.get_Item(1);
// Get the range of cells which has data.
Excel.Range xlRange = xlWorksheet.UsedRange;
// Get an object array of all of the cells in the worksheet with their values.
object[,] valueArray = (object[,])xlRange.get_Value(
Excel.XlRangeValueDataType.xlRangeValueDefault);
for (int row = 1; row <= xlWorksheet.UsedRange.Rows.Count; ++row)
{
for (int col = 1; col <= xlWorksheet.UsedRange.Columns.Count; ++col)
{
Console.WriteLine(valueArray[row, col].ToString());
}
int y = xlWorksheet.UsedRange.Rows.Count/4;
for() {
Console.WriteLine("4 addresat e para u printuan");
Console.WriteLine(" ");
}
}