当前位置: 首页>>代码示例>>C#>>正文


C# Workbook.SaveCopyAs方法代码示例

本文整理汇总了C#中Workbook.SaveCopyAs方法的典型用法代码示例。如果您正苦于以下问题:C# Workbook.SaveCopyAs方法的具体用法?C# Workbook.SaveCopyAs怎么用?C# Workbook.SaveCopyAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Workbook的用法示例。


在下文中一共展示了Workbook.SaveCopyAs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompareLogs


//.........这里部分代码省略.........
                            // if (MainForm.StopGracefully)
                            // break;

                            // Sortera på new
                            var column = GetStandardExcelColumnName(colums + 1);
                            var range = newWorksheet.Range["A4", column + rows.ToString(CultureInfo.InvariantCulture)];

                            // "IV"
                            if (name != "DatabaseInfo")
                            {
                                range.Sort(
                                    range.Columns[colums + 1, Type.Missing],
                                    XlSortOrder.xlDescending,
                                    // För att felsöka Excelprogrammering, använd macroEdit for VB i excel...
                                    // range.Columns[2,Type.Missing], Type.Missing, Excel.XlSortOrder.xlDescending
                                    Type.Missing,
                                    Type.Missing,
                                    XlSortOrder.xlDescending,
                                    Type.Missing,
                                    XlSortOrder.xlDescending,
                                    XlYesNoGuess.xlNo,
                                    Type.Missing,
                                    Type.Missing,
                                    XlSortOrientation.xlSortColumns,
                                    // ReSharper disable RedundantArgumentDefaultValue
                                    XlSortMethod.xlPinYin,
                                    XlSortDataOption.xlSortNormal,
                                    XlSortDataOption.xlSortNormal,
                                    XlSortDataOption.xlSortNormal);

                                // ReSharper restore RedundantArgumentDefaultValue
                            }

                            // Ta bort "new"-kolumnen
                            range = newWorksheet.Range[column + 1, column + rows.ToString(CultureInfo.InvariantCulture)];

                            // "IV"
                            range.Delete(Type.Missing); // false//(object)false);//

                            // För old o diff överskriften...
                            if (name == "DatabaseInfo")
                            {
                                range = newWorksheet.Range["C:D", "C:D"];
                                range.EntireColumn.AutoFit(); // autofittar hela columnen för all som loggas
                            }

                            // newWorksheet.set
                            #endregion
                        }

                        // if (MainForm.StopGracefully)
                        // break;
                    }
                    else
                    {
                        Console.WriteLine(name + " didn't exist in old Excel book.");
                    }

                    // oldBook.Add(name, oldRows);

                    // _compareProgress.SetTotal(++sheetsDone);
                }

                // Spara en ny fil
                // newLog.FullName = newLog.FullName + "-Compared";
                // newLog.Save();// .Save();
                newLogFileName = newLog.FullName.Replace(".xls", string.Empty) + "-Compared" + ".xls";
                newLog.SaveCopyAs(newLogFileName); // MainForm.LastLogPath);//newLog.FullName + "-Compared");
                newLog.Close(false, Type.Missing, Type.Missing);

                // _book.Close(false, Type.Missing, Type.Missing);
                excelApp.Quit();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
                excelApp = null;
            }
            catch (Exception e)
            {
                // MessageBox.Show("Error in comparing old log with new log. Was the log opened in Excel during compare processing?\r\n\r\n(Sys err: " + e.Message + ").");
                // throw e;
                throw new Exception(
                    "Error in comparing old log with new log. Was the log opened in Excel during compare processing?\r\n\r\n(Sys err: "
                    + e.Message + ").",
                    e);
            }

            #endregion - read new

            System.Threading.Thread.CurrentThread.CurrentCulture = oldCi;

            // MainForm.ShowTextProgress = false;//Visar inte ens texten längre
            // MainForm.ShowProgress = orgProgresSetting;//Håller på vad progress vad satt till innan

            // Stäng Excel
            if (excelApp != null)
            {
                excelApp.Quit();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
                excelApp = null;
            }
        }
开发者ID:perragradeen,项目名称:webbankbudgeter,代码行数:101,代码来源:ExcelLogRowComparer.cs


注:本文中的Workbook.SaveCopyAs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。