Private Sub SaveBook(action As Action(Of C1XLBook))
Dim dlg = New SaveFileDialog()
dlg.Filter = "Excel Files (*.xlsx)|*.xlsx"
If dlg.ShowDialog() = True Then
Try
Dim book = New C1XLBook()
action(book)
Using stream = dlg.OpenFile()
book.Save(stream)
End Using
Catch x As Exception
MessageBox.Show(x.Message)
End Try
End If
End Sub
コードのコピー
privatevoid SaveBook(Action<C1XLBook> action)
{
var dlg = new SaveFileDialog();
dlg.Filter = "Excel Files (*.xlsx)|*.xlsx";
if (dlg.ShowDialog() == true)
{
try
{
var book = new C1XLBook();
if (action != null)
{
action(book);
}
using (var stream = dlg.OpenFile())
{
book.Save(stream);
}
}
catch (Exception x)
{
MessageBox.Show(x.Message);
}
}
}