Search Results for 'vb2005'

ATOM Icon

1 POSTS

  1. 2007/12/16 C1FlexGrid -> Excel 출력 by shiftkey

C1FlexGrid -> Excel 출력

주의) office 2000이 설치된 PC에서는 cell width 설정이 적용 안됨

Private Sub btnExcel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExcel.Click
Dim xlApp As Microsoft.Office.Interop.Excel.Application
Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet

Dim fileName As String = "C:\grid.xls"

'폴더 지정
'Dim path As New FolderBrowserDialog
'If path.ShowDialog() = DialogResult.OK Then
' filePath = path.SelectedPath
'End If


Try
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.Filter = "Excel|*.xls"
saveFileDialog1.Title = "Save an Excel File"
If saveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
fileName = saveFileDialog1.FileName

cfgMaster.SaveExcel(fileName, "파일명", C1.Win.C1FlexGrid.FileFlags.IncludeMergedRanges)
Try
xlApp = CType(GetObject(, "Excel.Application"), Microsoft.Office.Interop.Excel.Application)
Catch ex As Exception
xlApp = CType(CreateObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)
End Try
xlApp.Workbooks.Open(fileName)
xlBook = xlApp.ActiveWorkbook
xlSheet = xlApp.ActiveSheet
xlSheet.StandardWidth = 15
xlApp.Worksheets.Application.ActiveWorkbook.Save()

'xlApp.Visible = True
xlApp.Quit()
End If
Catch ex As Exception

End Try

xlSheet = Nothing
xlBook = Nothing
xlApp = Nothing
GC.Collect()

End Sub


C1 Component 인 C1FlexGrid로 출력하면 각 셀의 사이즈가 모두 줄어들어 버리는데
엑셀을 다시 열어서 셀 너비를 15로 고정 시켰다.

.Net에서는 메모리 관리를 .Net에서 하기 때문에 GC.Collect()로 메모리에 떠 있는 Excel프로세서를 바로 죽여 버린다.

C1FlexGrid에서 엑셀 출력하면 셀 사이즈 설정이 안된다는 것을 찾아내는데 오랜 시간을 소비했다.

아까운 내 시간 ㅠ.ㅠ


크리에이티브 커먼즈 라이센스
Creative Commons License

Posted by shiftkey

2007/12/16 17:38 2007/12/16 17:38
, , , ,
Response
No Trackback , No Comment
RSS :
http://shiftkey.org/rss/response/115


블로그 이미지

Shiftkey가 살아가는 이런 저런 이야기......

- shiftkey

Notices

Archives

Authors

  1. shiftkey

Calendar

«   2012/05   »
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Site Stats

Total hits:
161252
Today:
33
Yesterday:
243