本文整理汇总了C#中Aspose.GetDisplayStyle方法的典型用法代码示例。如果您正苦于以下问题:C# Aspose.GetDisplayStyle方法的具体用法?C# Aspose.GetDisplayStyle怎么用?C# Aspose.GetDisplayStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aspose
的用法示例。
在下文中一共展示了Aspose.GetDisplayStyle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportBorders
/// <summary>
/// Import boreders from Excel cell to Word Cell
/// </summary>
/// <param name="wordsCell">Destination Word cell</param>
/// <param name="excelCell">Source Excel cell</param>
private void ImportBorders(Aspose.Words.Tables.Cell wordsCell, Aspose.Cells.Cell excelCell)
{
//Set line style
wordsCell.CellFormat.Borders[Aspose.Words.BorderType.Bottom].LineStyle = ConvertLineStyle(excelCell.GetDisplayStyle().Borders[Aspose.Cells.BorderType.BottomBorder].LineStyle);
//Set line color
if (wordsCell.CellFormat.Borders[Aspose.Words.BorderType.Bottom].LineStyle != LineStyle.None)
wordsCell.CellFormat.Borders[Aspose.Words.BorderType.Bottom].Color = excelCell.GetDisplayStyle().Borders[Aspose.Cells.BorderType.BottomBorder].Color;
wordsCell.CellFormat.Borders[Aspose.Words.BorderType.DiagonalDown].LineStyle = ConvertLineStyle(excelCell.GetDisplayStyle().Borders[Aspose.Cells.BorderType.DiagonalDown].LineStyle);
if (wordsCell.CellFormat.Borders[Aspose.Words.BorderType.DiagonalDown].LineStyle!= LineStyle.None)
wordsCell.CellFormat.Borders[Aspose.Words.BorderType.DiagonalDown].Color = excelCell.GetDisplayStyle().Borders[Aspose.Cells.BorderType.DiagonalDown].Color;
wordsCell.CellFormat.Borders[Aspose.Words.BorderType.DiagonalUp].LineStyle = ConvertLineStyle(excelCell.GetDisplayStyle().Borders[Aspose.Cells.BorderType.DiagonalUp].LineStyle);
if (wordsCell.CellFormat.Borders[Aspose.Words.BorderType.DiagonalUp].LineStyle!= LineStyle.None)
wordsCell.CellFormat.Borders[Aspose.Words.BorderType.DiagonalUp].Color = excelCell.GetDisplayStyle().Borders[Aspose.Cells.BorderType.DiagonalUp].Color;
wordsCell.CellFormat.Borders[Aspose.Words.BorderType.Left].LineStyle = ConvertLineStyle(excelCell.GetDisplayStyle().Borders[Aspose.Cells.BorderType.LeftBorder].LineStyle);
if (wordsCell.CellFormat.Borders[Aspose.Words.BorderType.Left].LineStyle != LineStyle.None)
wordsCell.CellFormat.Borders[Aspose.Words.BorderType.Left].Color = excelCell.GetDisplayStyle().Borders[Aspose.Cells.BorderType.LeftBorder].Color;
wordsCell.CellFormat.Borders[Aspose.Words.BorderType.Right].LineStyle = ConvertLineStyle(excelCell.GetDisplayStyle().Borders[Aspose.Cells.BorderType.RightBorder].LineStyle);
if (wordsCell.CellFormat.Borders[Aspose.Words.BorderType.Right].LineStyle != LineStyle.None)
wordsCell.CellFormat.Borders[Aspose.Words.BorderType.Right].Color = excelCell.GetDisplayStyle().Borders[Aspose.Cells.BorderType.RightBorder].Color;
wordsCell.CellFormat.Borders[Aspose.Words.BorderType.Top].LineStyle = ConvertLineStyle(excelCell.GetDisplayStyle().Borders[Aspose.Cells.BorderType.TopBorder].LineStyle);
if (wordsCell.CellFormat.Borders[Aspose.Words.BorderType.Top].LineStyle != LineStyle.None)
wordsCell.CellFormat.Borders[Aspose.Words.BorderType.Top].Color = excelCell.GetDisplayStyle().Borders[Aspose.Cells.BorderType.TopBorder].Color;
}
示例2: GetTextFromCell
/// <summary>
/// Get text with formating from Excel cell
/// </summary>
/// <param name="cell">Input Excel cell</param>
/// <param name="doc">Parent document</param>
/// <returns>Run that contains text with formating</returns>
private ArrayList GetTextFromCell(Aspose.Cells.Cell cell, Document doc)
{
//Create new array list
//We will store runs in this list
ArrayList wordRuns = new ArrayList();
//Get Chracters objects from the cell
FontSetting[] charactersList = cell.GetCharacters();
if (charactersList == null)
charactersList = new FontSetting[0];
//Get sring value from the cell
string cellValue = cell.StringValue;
//If there is some formatig in the cell
//charactersList will contains one or more Characters objects
//And we should create collection of Runs that will represent this formating
if (charactersList.Length > 0)
{
int startIndex = ((FontSetting)charactersList[0]).StartIndex;
if (startIndex > 0)
{
//Create first run
Run firstRun = new Run(doc);
//Set text of first run. That will be substring that starts from 0
//And ens and the start position of first Characters object
//Sometimes Aspose.Cell returns incorrect index so we should check it
if (startIndex < cellValue.Length)
firstRun.Text = cellValue.Substring(0, startIndex);
else
firstRun.Text = cellValue.Substring(0);
//Formation of first run will be the same as formating of whole cell
ImportFont(firstRun.Font, cell.GetDisplayStyle().Font);
wordRuns.Add(firstRun);
}
//Loop through all Character objects
foreach (FontSetting chars in charactersList)
{
Run run = new Run(doc);
//We should check index to avoid errors
if (chars.StartIndex < cellValue.Length)
{
if (cellValue.Length > (chars.StartIndex + chars.Length) && chars.Length > 0)
run.Text = cellValue.Substring(chars.StartIndex, chars.Length);
else
run.Text = cellValue.Substring(chars.StartIndex);
}
//Convert Excel Font to Words Font
ImportFont(run.Font, chars.Font);
wordRuns.Add(run);
}
}
//Othervice there will be only one run
else
{
Run run = new Run(doc);
run.Text = cellValue;
//Convert Excel Font to Words Font
ImportFont(run.Font, cell.GetDisplayStyle().Font);
wordRuns.Add(run);
}
return wordRuns;
}