Umbruch Cell Text

Umbruch Cell Text

So erstellen Sie ein Arbeitsblatt mit zwei Zellen, eine mit umbrochenem Text und eine ohne:

  1. Erstellen Sie das Arbeitsblatt:
  2. Erstellen Sie eine Arbeitsmappe.
  3. Greifen Sie auf das erste Arbeitsblatt zu.
  4. Text hinzufügen:
  5. Fügen Sie Text zu Zelle A1 hinzu.
  6. Fügen Sie umgebrochenen Text zu Zelle A5 hinzu.
  7. Speichern Sie die Tabelle.

Die folgenden Codebeispiele zeigen, wie Sie diese Schritte mit ausführenVSTO entweder mit C# oder Visual Basic. Codebeispiele, die zeigen, wie man dasselbe mit machtAspose.Cells for .NET, wiederum mit entweder C# oder Visual Basic folgen unmittelbar danach.

Das Ausführen des Codes führt zu einer Tabelle mit zwei Zellen, eine mit nicht umbrochenem Text und eine mit:

Geben Sie den Zellentext mit VSTO aus

todo: Bild_alt_Text

Zeilenumbruchtext mit Aspose.Cells for .NET ausgeben

todo: Bild_alt_Text

Umbruch von Cell Text mit VSTO

C#

 //Note: To help you better, the code uses full namespacing

void WrappingCellText()

{

    //Access vsto application

    Microsoft.Office.Interop.Excel.Application app = Globals.ThisAddIn.Application;

    //Access workbook 

    Microsoft.Office.Interop.Excel.Workbook workbook = app.ActiveWorkbook;

    //Access worksheet 

    Microsoft.Office.Interop.Excel.Worksheet m_sheet = workbook.Worksheets[1];

    //Access vsto worksheet

    Microsoft.Office.Tools.Excel.Worksheet sheet = Globals.Factory.GetVstoObject(m_sheet);

    //Place some text in cell A1 without wrapping

    Microsoft.Office.Interop.Excel.Range cellA1 = sheet.Cells.get_Range("A1");

    cellA1.Value = "Sample Text Unwrapped";

    //Place some text in cell A5 with wrapping

    Microsoft.Office.Interop.Excel.Range cellA5 = sheet.Cells.get_Range("A5");

    cellA5.Value = "Sample Text Wrapped";

    cellA5.WrapText = true;

    //Save the workbook

    workbook.SaveAs("f:\\downloads\\OutputVsto.xlsx");

    //Quit the application

    app.Quit();

}

Umbruch von Cell Text mit Aspose.Cells for .NET

C#

 void WrappingCellText()

{

    //Create workbook

    Workbook workbook = new Workbook();

    //Access worksheet

    Worksheet worksheet = workbook.Worksheets[0];

    //Place some text in cell A1 without wrapping

    Cell cellA1 = worksheet.Cells["A1"];

    cellA1.PutValue("Some Text Unwrapped");

    //Place some text in cell A5 wrapping

    Cell cellA5 = worksheet.Cells["A5"];

    cellA5.PutValue("Some Text Wrapped");

    Style style = cellA5.GetStyle();

    style.IsTextWrapped = true;

    cellA5.SetStyle(style);

    //Autofit rows

    worksheet.AutoFitRows();

    //Save the workbook

    workbook.Save("f:\\downloads\\OutputAspose.xlsx", SaveFormat.Xlsx);

}