2009-09-02 3 views
1

Excel로 데이터를 내보내고 내 응용 프로그램에있는 폴더에 저장하려고합니다 ... Excel이 기본적으로 C : \ Documents에 저장되지만 저장하려고합니다. E에서 : \ Apllication \ 여기 Excel이 C : \ MyDocuments에 저장됩니다. 기본적으로

엑셀 시트를

If ComDset.Tables(0).Rows.Count > 0 Then 

     Try 
      With Excel 
       .SheetsInNewWorkbook = 1 
       .Workbooks.Add() 
       .Worksheets(1).Select() 

       Dim i As Integer = 1 
       For col = 0 To ComDset.Tables(0).Columns.Count - 1 
        .cells(1, i).value = ComDset.Tables(0).Columns(col).ColumnName 
        .cells(1, i).EntireRow.Font.Bold = True 
        i += 1 
       Next 
       i = 2 
       Dim k As Integer = 1 
       For col = 0 To ComDset.Tables(0).Columns.Count - 1 
        i = 2 
        For row = 0 To ComDset.Tables(0).Rows.Count - 1 
         .Cells(i, k).Value = ComDset.Tables(0).Rows(row).ItemArray(col) 
         i += 1 
        Next 
        k += 1 
       Next 
       filename = "ShiftReport" & Format(MdbDate, "dd-MM-yyyy") & ".xls" 
       .ActiveCell.Worksheet.SaveAs(filename) 
      End With 
      System.Runtime.InteropServices.Marshal.ReleaseComObject(Excel) 
      Excel = Nothing 
     Catch ex As Exception 
      MsgBox(ex.Message) 
     End Try 

     ' The excel is created and opened for insert value. We most close this excel using this system 
     Dim pro() As Process = System.Diagnostics.Process.GetProcessesByName("EXCEL") 
     For Each i As Process In pro 
      i.Kill() 
     Next 
    End If 

를 생성하고

+0

"머리글에 색 지정"? .Cells (1, i) .EntireRow.Interior.Color = RGB (0, 255, 0) (녹색의 경우, 분명히를 선택하십시오. 원하는 색상의 적절한 RGB 값) 또는 .Cells (1, i) .EntireRow.Interior.ColorIndex = 14 (파란색 정렬의 경우 형식> 셀> 패턴의 팔레트에 해당합니다. -1에서 56까지의 값) – barrowc

답변

3

가지고 사전에 헤더에

감사 색을 지정하는 방법을 말해 내 코드를보고 너 이거 썼어?

.ActiveCell.Worksheet.SaveAs("E:\Apllication\Reports\" & filename) 
관련 문제