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


C# Worksheet.SaveAs方法代码示例

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


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

示例1: SaveExcelFile

        public static void SaveExcelFile(string fileName, string tempFileName,string[,] contents, int startColumn, int startRow)
        {
            try
            {
                excelApp = new ApplicationClass();
                Workbooks myWorkBooks = excelApp.Workbooks;
                myWorkBooks.Open(tempFileName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
                Sheets sheets = excelApp.Sheets;
                mySheet1 = (Worksheet)sheets[1];
                mySheet1.Activate();

                //写入测试信息
                Range range1 = mySheet1.get_Range(mySheet1.Cells[startRow, startColumn], mySheet1.Cells[contents.GetLength(0)+startRow-1,contents.GetLength(1)+startColumn-1]);
                range1.Value2 = contents;
                mySheet1.SaveAs(fileName, missing, missing, missing, missing, missing, missing, missing, missing, missing);
                myWorkBooks.Close();
                excelApp.Quit();
                excelApp = null;
            }
            catch (Exception ee)
            {

                throw ee;
            }
        }
开发者ID:dewade2003,项目名称:apple,代码行数:25,代码来源:ExcelUtil.cs

示例2: SaveWorkSheet

        static void SaveWorkSheet(Worksheet sheet, string csvFileName, XlFileFormat format, bool quiet, bool prompt)
        {
            if(!quiet) Console.Error.WriteLine("Saving worksheet {0} to file '{1}'", sheet.Name, csvFileName);
            csvFileName = Path.Combine(Environment.CurrentDirectory, csvFileName);

            if (File.Exists(csvFileName))
            {
                if (prompt)
                {
                    Console.Error.Write("The file {0} exists. Replace (Y/n)?", Path.GetFileName(csvFileName));
                    var input = Console.ReadLine();
                    if (input == "n") return;
                }

                File.Delete(csvFileName);
            }
            sheet.SaveAs(csvFileName, format);
        }
开发者ID:nithinphilips,项目名称:exceltocsv,代码行数:18,代码来源:Program.cs


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