Satırları ve Sütunları Biçimlendir
Satırlarla Çalışmak
Satır Yüksekliğini Ayarlama
Aspose.Cells bir sınıf sağlar,Çalışma kitabı , bu bir Microsoft Excel dosyasını temsil eder. buÇalışma kitabı sınıf bir içerirÇalışma Sayfası KoleksiyonuExcel dosyasındaki her çalışma sayfasına erişim sağlar. Bir çalışma sayfası şununla temsil edilir:Çalışma kağıdı sınıf. buÇalışma kağıdı sınıf bir sağlarCellsçalışma sayfasındaki tüm hücreleri temsil eden koleksiyon.
buCellskoleksiyon, bir çalışma sayfasındaki satırları veya sütunları yönetmek için çeşitli yöntemler sağlar. Bunlardan bazıları aşağıda daha ayrıntılı olarak tartışılmaktadır.
Bir Satırın Yüksekliğini Ayarlama
çağırarak tek bir satırın yüksekliğini ayarlamak mümkündür.Cells koleksiyonunSatır Yüksekliğini Ayarla yöntem. buSatır Yüksekliğini Ayarlamethod aşağıdaki gibi parametreleri alır:
- Satır dizini, yüksekliğini değiştirdiğiniz satırın dizini.
- Satır yüksekliği, satıra uygulanacak satır yüksekliği.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Creating a file stream containing the Excel file to be opened | |
FileStream fstream = new FileStream(dataDir + "book1.xls", FileMode.Open); | |
// Instantiating a Workbook object | |
// Opening the Excel file through the file stream | |
Workbook workbook = new Workbook(fstream); | |
// Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Setting the height of the second row to 13 | |
worksheet.Cells.SetRowHeight(1, 13); | |
// Saving the modified Excel file | |
workbook.Save(dataDir + "output.out.xls"); | |
// Closing the file stream to free all resources | |
fstream.Close(); |
Çalışma Sayfasındaki Tüm Satırların Yüksekliğini Ayarlama
Geliştiricilerin çalışma sayfasındaki tüm satırlar için aynı satır yüksekliğini ayarlamaları gerekirse, bunuStandart Yükseklik mülkiyetiCellsToplamak.
Örnek vermek:
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Creating a file stream containing the Excel file to be opened | |
FileStream fstream = new FileStream(dataDir + "book1.xls", FileMode.Open); | |
// Instantiating a Workbook object | |
// Opening the Excel file through the file stream | |
Workbook workbook = new Workbook(fstream); | |
// Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Setting the height of all rows in the worksheet to 15 | |
worksheet.Cells.StandardHeight = 15; | |
// Saving the modified Excel file | |
workbook.Save(dataDir + "output.out.xls"); | |
// Closing the file stream to free all resources | |
fstream.Close(); |
Sütunlarla Çalışmak
Bir Sütunun Genişliğini Ayarlama
öğesini çağırarak bir sütunun genişliğini ayarlayın.Cells koleksiyonunSütun Genişliğini Ayarla yöntem. buSütun Genişliğini Ayarlayöntem aşağıdaki parametreleri alır:
- Sütun dizini, genişliğini değiştirdiğiniz sütunun dizini.
- Sütun genişliği, istenen sütun genişliği.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Creating a file stream containing the Excel file to be opened | |
FileStream fstream = new FileStream(dataDir + "book1.xls", FileMode.Open); | |
// Instantiating a Workbook object | |
// Opening the Excel file through the file stream | |
Workbook workbook = new Workbook(fstream); | |
// Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Setting the width of the second column to 17.5 | |
worksheet.Cells.SetColumnWidth(1, 17.5); | |
// Saving the modified Excel file | |
workbook.Save(dataDir + "output.out.xls"); | |
// Closing the file stream to free all resources | |
fstream.Close(); |
Sütun Genişliğini Piksel Olarak Ayarlama
öğesini çağırarak bir sütunun genişliğini ayarlayın.CellskoleksiyonunSetColumnWidthPixelyöntem. buSetColumnWidthPixelyöntem aşağıdaki parametreleri alır:
- Sütun dizini, genişliğini değiştirdiğiniz sütunun dizini.
- Sütun genişliğipiksel cinsinden istenen sütun genişliği.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
//Source directory | |
string sourceDir = RunExamples.Get_SourceDirectory(); | |
string outDir = RunExamples.Get_OutputDirectory(); | |
//Load source Excel file | |
Workbook workbook = new Workbook(sourceDir + "Book1.xlsx"); | |
//Access first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Set the width of the column in pixels | |
worksheet.Cells.SetColumnWidthPixel(7, 200); | |
workbook.Save(outDir + "SetColumnWidthInPixels_Out.xlsx"); |
Çalışma Sayfasındaki Tüm Sütunların Genişliğini Ayarlama
Çalışma sayfasındaki tüm sütunlar için aynı sütun genişliğini ayarlamak üzereCells koleksiyonunStandart GenişlikEmlak.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create directory if it is not already present. | |
bool IsExists = System.IO.Directory.Exists(dataDir); | |
if (!IsExists) | |
System.IO.Directory.CreateDirectory(dataDir); | |
// Creating a file stream containing the Excel file to be opened | |
FileStream fstream = new FileStream(dataDir + "book1.xls", FileMode.Open); | |
// Instantiating a Workbook object | |
// Opening the Excel file through the file stream | |
Workbook workbook = new Workbook(fstream); | |
// Accessing the first worksheet in the Excel file | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Setting the width of all columns in the worksheet to 20.5 | |
worksheet.Cells.StandardWidth = 20.5; | |
// Saving the modified Excel file | |
workbook.Save(dataDir + "output.out.xls"); | |
// Closing the file stream to free all resources | |
fstream.Close(); |
ileri konular
- Satırları ve Sütunları Otomatik Sığdır
- Aspose.Cells’i kullanarak Metni Sütunlara Dönüştür
- Satırları ve Sütunları Kopyalama
- Çalışma Sayfasındaki Boş Satırları ve Sütunları Silme
- Satırları ve Sütunları Gruplandırma ve Grubu Çözme
- Satırları ve Sütunları Gizleme ve Gösterme
- Excel Çalışma Sayfasına Satır Ekleme veya Silme
- Excel dosyasına Satır ve Sütun Ekleme ve Silme
- Çalışma Sayfasındaki yinelenen satırları kaldırın
- Bir çalışma sayfasındaki boş sütunları ve satırları silerken diğer çalışma sayfalarındaki referansları güncelleyin