We have one excel workbook with one sheet. It is of 2 GB, can we split that excel file so that number of rows are equally distributed to split sheet. Please let me know sample C# code for the same.
You can specify the number of rows a single page will include.
The code example as well as screenshot that shows how it works can be found in Split a worksheet into pages by rows topic.
Will this code not work to split CSV files into Multiple files -
// Split CSV file using GroupDocs.Merger API
string filePath = “D:/Shared Files/Input/ExcelSplit/EMEAExpenseGrouping.xlsx”;
string filePathOut = “D:/Shared Files/Input/ExcelSplit/EMEAExpenseGroupingSplit.xlsx”;
// Initialize SplitOptions class with output files path format
GroupDocs.Merger.Domain.Options.SplitOptions splitOptions = new GroupDocs.Merger.Domain.Options.SplitOptions(filePathOut, new int[] { 3, 6, 8 });
// Instantiate Merger with input CSV document
using (Merger merger = new Merger(filePath))
{
// Call Split method and pass SplitOptions object to save resultant documents
merger.Split(splitOptions);
}
@Mufaddal53
It looks like you are using GroupDocs.Merger for .NET API. We have opened the following new investigation ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): MERGERNET-1475
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Kindly give the code from this article a try. Feel free to reach out if you encounter any challenges.
It is 2 GB CSV file, not a text file.
How to mention the path of CSV and file name in path ?
Please take a look at the following code. It clearly explains how to add CSV file.
// Specify the input file path
string filePath = @"c:\sample.csv";
// Specify the output file format and path pattern using placeholders for line number and extension
string filePathOut = @"c:\output\line_{0}.{1}";
// Define the options for splitting the text file
TextSplitOptions splitOptions = new TextSplitOptions(filePathOut, new int[] { 3, 6 });
// Create a "using" block to ensure proper disposal of resources
using (Merger merger = new Merger(filePath))
{
// Split the input text file based on the provided split options
merger.Split(splitOptions);
}