1 /// 2 /// 導入Excel文件按鈕 3 /// 4 /// 5 /// 6 private void InputExcelFile_Click(object sender, RoutedEventArgs e) 7 { 8 //將數... ...
1 /// <summary> 2 /// 導入Excel文件按鈕 3 /// </summary> 4 /// <param name="sender"></param> 5 /// <param name="e"></param> 6 private void InputExcelFile_Click(object sender, RoutedEventArgs e) 7 { 8 //將數據綁定到datagird控制項中 9 DataGridSheet.ItemsSource = readbynpoi.InputWorkbookFromExcel(GetExcelFilePath()); 10 DataGridSheet.HeadersVisibility = DataGridHeadersVisibility.Row; 11 DataGridSheet.RowHeaderWidth = 30; 12 //LoadingRow事件 13 DataGridSheet.LoadingRow += DataGridSheet_LoadingRow; 14 } 15 16 private void DataGridSheet_LoadingRow(object sender, DataGridRowEventArgs e) 17 { 18 e.Row.Header = e.Row.GetIndex() + 1;//遞增行號 19 }