ファイルの保存
Contents
[
Hide
]
Aspose.Cells を使用すると、ファイルの作成と保存、および既存のファイルの操作が可能になります。この記事では、ファイルを保存するさまざまな方法について説明します。
ファイルを保存するさまざまな方法
Aspose.Cells はIワークブックこれは Microsoft Excel ファイルを表し、Excel ファイルを操作するために必要なメソッドを提供します。のIワークブッククラスが提供するセーブExcelファイルを保存するために使用される方法。のセーブメソッドには、さまざまな方法でファイルを保存するために使用される多くのオーバーロードがあります。ファイルが保存されるファイル形式は、SaveFormat列挙。
ファイルをある場所に保存する
ファイルを保存場所に保存するには、ファイル名 (保存パスを含む) と目的のファイル形式 (SaveFormat列挙) を呼び出すときIワークブックオブジェクトのセーブ方法。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\LoadingSavingAndConverting\\"); | |
//Output directory path | |
StringPtr outPath = new String("..\\Data\\Output\\"); | |
//Load sample Excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(dirPath->StringAppend(new String("sampleExcelFile.xlsx"))); | |
//Save in Excel 97-2003 format | |
workbook->Save(outPath->StringAppend(new String("outputSavingFiletoSomeLocationExcel97-2003.xls"))); | |
//OR | |
workbook->Save(outPath->StringAppend(new String("outputSavingFiletoSomeLocationOrExcel97-2003.xls")), SaveFormat_Excel97To2003); | |
//Save in Excel2007 xlsx format | |
workbook->Save(outPath->StringAppend(new String("outputSavingFiletoSomeLocationXlsx.xlsx")), SaveFormat_Xlsx); |
ストリームへのファイルの保存
ファイルをストリームに保存するには、MemoryStream または FileStream オブジェクトを作成し、 を呼び出してファイルをそのストリーム オブジェクトに保存します。Iワークブックオブジェクトのセーブ方法。を使用して目的のファイル形式を指定します。SaveFormatを呼び出すときの列挙セーブ方法。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Source directory path | |
StringPtr dirPath = new String("..\\Data\\LoadingSavingAndConverting\\"); | |
//Output directory path | |
StringPtr outPath = new String("..\\Data\\Output\\"); | |
//Load sample Excel file | |
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook(dirPath->StringAppend(new String("sampleExcelFile.xlsx"))); | |
//Create FileStream object | |
intrusive_ptr<FileStream> stream = new FileStream(outPath->StringAppend(new String("outputSavingFiletoStream.xlsx")), FileMode_CreateNew); | |
//Save the Workbook to Stream | |
workbook->Save(stream, SaveFormat_Xlsx); | |
stream->Close(); |