다음을 통해 공유


ExportToStream() 메서드를 위한 프로젝트 준비

이 부분에서는 "새 내보내기 형식의 메서드 만들기" 절차에서 작성된 프로젝트를 수정하는 방법을 설명합니다.

이 과정에서는 ExportToStream() 메서드에 필요하지 않은 몇몇 코드 줄을 삭제해야 합니다.

ExportToStream() 메서드를 사용할 수 있도록 프로젝트를 수정하려면

  1. 프로젝트를 엽니다.

  2. Web Form 또는 Windows Form을 엽니다.

  3. 보기 메뉴에서 코드를 클릭합니다.

  4. 클래스의 맨 위에서 다음과 같은 클래스 선언을 삭제합니다.

    Private myDiskFileDestinationOptions As DiskFileDestinationOptions
    Private myExportOptions As ExportOptions
    
    private DiskFileDestinationOptions diskFileDestinationOptions;
    private ExportOptions exportOptions;
    
  5. ExportSetup() 메서드 안에서 조건 블록 다음에 있는 코드 줄을 모두 삭제합니다. ExportFormatOptions 속성을 호출하는 마지막 코드 줄은 Windows 프로젝트에만 사용되고 있습니다.

    myDiskFileDestinationOptions = New DiskFileDestinationOptions()
    myExportOptions = hierarchicalGroupingReport.ExportOptions
    myExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
    myExportOptions.ExportFormatOptions = Nothing
    
    diskFileDestinationOptions = new DiskFileDestinationOptions();
    exportOptions = hierarchicalGroupingReport.ExportOptions;
    exportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
    exportOptions.ExportFormatOptions = null;
    
  6. 다음과 같은 내보내기 구성 메서드를 삭제합니다.

    • ConfigureExportToRpt()
    • ConfigureExportToRtf()
    • ConfigureExportToDoc()
    • ConfigureExportToXls()
    • ConfigureExportToPdf()
    • ConfigureExportToHtml32()
    • ConfigureExportToHtml40()
    • ConfigureExportToXlsRec()
  7. ExportSelection()의 Select Case [Visual Basic] 또는 switch [C#] case 문 안에서 내보내기 구성 메서드에 대한 호출을 삭제합니다.

  8. ExportCompletion() 메서드 안에서 Export() 메서드에 대한 호출을 삭제합니다.

  9. ExportCompletion() 메서드의 코드를 모두 복사하여 ExportSelection() 메서드의 맨 위에 붙여넣습니다.

  10. ExportCompletion() 메서드를 삭제하고 exportByType 단추 클릭 이벤트에서 ExportCompletion()에 대한 호출을 삭제합니다.

  11. ExportSelection() 메서드 안에서 Select Case [Visual Basic] 또는 switch [C#] case 문을 잘라내 try 블록 안의 If 블록 위에 붙여넣습니다.

    try/catch 블록은 이제 다음과 같이 표시되어야 합니다.

    Try
    Select Case exportTypesList.SelectedIndex
    Case ExportFormatType.NoFormat
    selectedNoFormat = True
    Case ExportFormatType.CrystalReport
    
    Case ExportFormatType.RichText
    
    Case ExportFormatType.WordForWindows
    
    Case ExportFormatType.Excel
    
    Case ExportFormatType.PortableDocFormat
    
    Case ExportFormatType.HTML32
    
    Case ExportFormatType.HTML40
    
    End Select
    If selectedNoFormat Then
    message.Text = MessageConstants.FORMAT_NOT_SUPPORTED
    Else
    message.Text = MessageConstants.SUCCESS
    End If
    Catch ex As Exception
    message.Text = MessageConstants.FAILURE & ex.Message
    End Try
    
    try
    {
    switch ((ExportFormatType)exportTypesList.SelectedIndex)
    {
    case ExportFormatType.NoFormat:
    selectedNoFormat = true;
    break;
    case ExportFormatType.CrystalReport:
    break;
    case ExportFormatType.RichText:
    break;
    case ExportFormatType.WordForWindows:
    break;
    case ExportFormatType.Excel:
    break;
    case ExportFormatType.PortableDocFormat:
    break;
    case ExportFormatType.HTML32:
    break;
    case ExportFormatType.HTML40:
    break;
    case ExportFormatType.ExcelRecord:
    break;
    }
    if (selectedNoFormat)
    {
    message.Text = MessageConstants.FORMAT_NOT_SUPPORTED;
    }
    else
    {
    message.Text = MessageConstants.SUCCESS;
    }
    }
    catch (Exception ex)
    {
    message.Text = MessageConstants.FAILURE + ex.Message;
    }