Paketleme Cell Metin

Paketleme Cell Metin

Biri kaydırılmış metin içeren ve diğeri içermeyen iki hücreli bir çalışma sayfası oluşturmak için:

  1. Çalışma sayfasını ayarlayın:
  2. Bir çalışma kitabı oluşturun.
  3. İlk çalışma sayfasına erişin.
  4. Yazı ekle:
  5. A1 hücresine metin ekleyin.
  6. Kaydırılmış metni A5 hücresine ekleyin.
  7. Elektronik tabloyu kaydedin.

Aşağıdaki kod örnekleri, kullanarak bu adımların nasıl gerçekleştirileceğini gösterir.VSTO C# veya Visual Basic ile. kullanarak aynı şeyi nasıl yapacağınızı gösteren kod örnekleriAspose.Cells for .NET, yine C# veya Visual Basic kullanarak hemen ardından izleyin.

Kodun çalıştırılması, biri sarmalanmamış metin ve diğeri aşağıdakileri içeren iki hücreli bir elektronik tabloyla sonuçlanır:

VSTO ile çıktı sarma hücre metni

yapılacaklar:resim_alternatif_metin

Aspose.Cells for .NET ile çıktı sarma hücre metni

yapılacaklar:resim_alternatif_metin

Cell Metni VSTO Kullanarak Kaydırma

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();

}

Sarma Cell Metin Kullanılıyor 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);

}