本文整理汇总了C#中Aspose.GetColumnWidthPixel方法的典型用法代码示例。如果您正苦于以下问题:C# Aspose.GetColumnWidthPixel方法的具体用法?C# Aspose.GetColumnWidthPixel怎么用?C# Aspose.GetColumnWidthPixel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aspose
的用法示例。
在下文中一共展示了Aspose.GetColumnWidthPixel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportExcelCell
/// <summary>
/// Convert Excel Cell to Word Cell
/// </summary>
/// <param name="doc">Parent document</param>
/// <param name="cells">Excel cells collection</param>
/// <param name="rowIndex">Row index</param>
/// <param name="columnIndex">Column index</param>
/// <returns>Word Cell</returns>
private Aspose.Words.Tables.Cell ImportExcelCell(Document doc, Aspose.Cells.Cells cells, int rowIndex, int columnIndex)
{
//Create a new Word Cell
Aspose.Words.Tables.Cell wordsCell = new Aspose.Words.Tables.Cell(doc);
//Get Excel cell from collection
Aspose.Cells.Cell excelCell = cells[rowIndex, columnIndex];
//Set cell width
double cellWidth = ConvertUtil.PixelToPoint(cells.GetColumnWidthPixel(columnIndex));
wordsCell.CellFormat.PreferredWidth = PreferredWidth.FromPoints(cellWidth);
wordsCell.CellFormat.Width = ConvertUtil.PixelToPoint(cellWidth);
//Set background color
wordsCell.CellFormat.Shading.ForegroundPatternColor = excelCell.GetDisplayStyle().ForegroundColor;
wordsCell.CellFormat.Shading.BackgroundPatternColor = excelCell.GetDisplayStyle().BackgroundColor;
//Set background texture
wordsCell.CellFormat.Shading.Texture = ConvertBackgroundTexture(excelCell.GetDisplayStyle().Pattern);
//Import borders from Excel cell to Word cell
ImportBorders(wordsCell, excelCell);
//Set vertical alignment
wordsCell.CellFormat.VerticalAlignment = ConvertVerticalAlignment(excelCell.GetDisplayStyle().VerticalAlignment);
//If Excel cells is merged then merge cells in Word Table
wordsCell.CellFormat.VerticalMerge = ConvertVerticalCellMerge(excelCell);
wordsCell.CellFormat.HorizontalMerge = ConvertHorizontalCellMerge(excelCell);
//Create paragraph that will containc content of cell
Paragraph wordsParagraph = new Paragraph(doc);
//Set horizontal alignment
wordsParagraph.ParagraphFormat.Alignment = ConvertHorizontalAlignment(excelCell.GetDisplayStyle().HorizontalAlignment);
//Get text with formating from Excel cell as collection Run
ArrayList wordRuns = GetTextFromCell(excelCell, doc);
foreach (Run run in wordRuns)
{
wordsParagraph.AppendChild(run);
}
//Import formating of the cell
ImportFont(wordsParagraph.ParagraphBreakFont, excelCell.GetDisplayStyle().Font);
//Insert paragrahp with content into cell
wordsCell.AppendChild(wordsParagraph);
//If Excel cell contains drawing object then convert this object and insert into Word cell
InsertDrawingObject(excelCell, wordsCell);
return wordsCell;
}