本文整理汇总了C#中Microsoft.Office.Interop.Excel.Application.CentimetersToPoints方法的典型用法代码示例。如果您正苦于以下问题:C# Application.CentimetersToPoints方法的具体用法?C# Application.CentimetersToPoints怎么用?C# Application.CentimetersToPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Office.Interop.Excel.Application
的用法示例。
在下文中一共展示了Application.CentimetersToPoints方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Export
private void Export()
{
string fileName = "Excel.xls";
var rep = (ReportPreviewModel.Report as OrderFormReport);
rep.ExportToXls(fileName, new XlsExportOptions());
Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();
Workbook ObjWorkBookGeneral;
ObjWorkBookGeneral = ObjExcel.Workbooks.Open(Environment.CurrentDirectory + "\\" + fileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
if (File.Exists(Environment.CurrentDirectory + "\\" + fileName))
File.Copy(Environment.CurrentDirectory + "\\" + fileName, Environment.CurrentDirectory + "\\Result_" + fileName, true);
Workbook ObjWorkBookResult = ObjExcel.Workbooks.Open(Environment.CurrentDirectory + "\\Result_" + fileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
(ObjWorkBookResult.ActiveSheet as Worksheet).UsedRange.Clear();
try
{
Worksheet sheet = ObjWorkBookGeneral.ActiveSheet;
if (sheet != null)
{
Range range = sheet.UsedRange;
if (range != null)
{
int nRows = range.Rows.Count;
int nCols = range.Columns.Count;
Range tempRange;
Range startCell = null;
Range endCell = null;
string animationName = string.Empty;
int currentSheetIndex = 0;
int k = 0;
for (int i = 1; i <= nRows + 1; i++)
{
string d = range[i, 1].value;
if (d == "xrStart" || i == nRows + 1)
{
k = 1;
if (startCell != null || i == nRows + 1)
{
endCell = range.Cells[i - 1, nCols];
tempRange = range.Range[startCell, endCell];
currentSheetIndex = currentSheetIndex + 1;
((Worksheet)ObjWorkBookResult.Sheets[currentSheetIndex]).Select(Type.Missing);
ObjWorkBookResult.ActiveSheet.Name = animationName;
tempRange.Copy(Type.Missing);
ObjWorkBookResult.ActiveSheet.PasteSpecial(XlPasteType.xlPasteColumnWidths);
ObjWorkBookResult.ActiveSheet.PasteSpecial(XlPasteType.xlPasteAllUsingSourceTheme);
(ObjWorkBookResult.ActiveSheet as Worksheet).PageSetup.Orientation = XlPageOrientation.xlLandscape;
(ObjWorkBookResult.ActiveSheet as Worksheet).PageSetup.TopMargin = ObjExcel.CentimetersToPoints(1);
(ObjWorkBookResult.ActiveSheet as Worksheet).PageSetup.BottomMargin = ObjExcel.CentimetersToPoints(1);
(ObjWorkBookResult.ActiveSheet as Worksheet).PageSetup.HeaderMargin = 0;
(ObjWorkBookResult.ActiveSheet as Worksheet).PageSetup.FooterMargin = 0;
(ObjWorkBookResult.ActiveSheet as Worksheet).PageSetup.LeftMargin = ObjExcel.CentimetersToPoints(1);
(ObjWorkBookResult.ActiveSheet as Worksheet).PageSetup.RightMargin = ObjExcel.CentimetersToPoints(1);
startCell = range.Cells[i, 1];
if (range.Cells[i + 1, 1].value != null)
{
animationName = range.Cells[i + 1, 1].value;
animationName = RemoveSpecialCharacters(animationName);
if (animationName.Length > 30)
animationName = animationName.Substring(0, 30);
ObjWorkBookResult.Sheets.Add(Type.Missing, ObjWorkBookResult.ActiveSheet,
Type.Missing, Type.Missing);
}
}
else
{
startCell = range.Cells[i, 1];
animationName = range.Cells[i + 1, 1].value;
animationName = RemoveSpecialCharacters(animationName);
if (animationName.Length > 30)
animationName = animationName.Substring(0, 30);
}
}
Worksheet sh = (ObjWorkBookResult.ActiveSheet as Worksheet);
(sh.Rows[k] as Range).RowHeight = (range.Rows[i] as Range).RowHeight;
k++;
}
}
}
}
finally
{
//.........这里部分代码省略.........