Sposta i fogli di lavoro all'interno della cartella di lavoro

Aspose.Cells fornisce un metodo, Aspose.Cells.Worksheet.MoveTo(), utilizzato per spostare un foglio di lavoro in un’altra posizione nel foglio di calcolo. Il metodo accetta l’indice del foglio di lavoro di destinazione come parametro.

L’esempio seguente mostra come spostare un foglio di lavoro in un’altra posizione all’interno della cartella di lavoro.

 string FilePath = @"..\..\..\Sample Files\";

string FileName = FilePath + "Move Worksheet.xlsx";

//Open an existing excel file.

Workbook wb = new Workbook(FileName);

//Create a Worksheets object with reference to

//the sheets of the Workbook.

WorksheetCollection sheets = wb.Worksheets;

//Get the first worksheet.

Worksheet worksheet = sheets[0];

string test = worksheet.Name;

//Move the first sheet to the third position in the workbook.

worksheet.MoveTo(2);

//Save the excel file.

wb.Save(FileName);

Scarica il codice di esempio