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


C# LoadOptions类代码示例

本文整理汇总了C#中LoadOptions的典型用法代码示例。如果您正苦于以下问题:C# LoadOptions类的具体用法?C# LoadOptions怎么用?C# LoadOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Run

        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            // Load only specific sheets with data and formulas
            // Other objects, items etc. would be discarded

            // Instantiate LoadOptions specified by the LoadFormat
            LoadOptions loadOptions7 = new LoadOptions(LoadFormat.Xlsx);

            // Set the LoadDataOption
            LoadDataOption dataOption = new LoadDataOption();
            // Specify the sheet(s) in the template file to be loaded
            dataOption.SheetNames = new string[] { "Sheet2" };
            dataOption.ImportFormula = true;
            // Only data and formatting should be loaded.
            loadOptions7.LoadDataAndFormatting = true;
            // Specify the LoadDataOption
            loadOptions7.LoadDataOptions = dataOption;

            // Create a Workbook object and opening the file from its path
            Workbook wb = new Workbook(dataDir + "Book1.xlsx", loadOptions7);
            Console.WriteLine("File data imported successfully!");
            // ExEnd:1
            
            }
开发者ID:aspose-cells,项目名称:Aspose.Cells-for-.NET,代码行数:27,代码来源:OpeningFilewithDataOnly.cs

示例2: Main

        static void Main(string[] args)
        {
            LoadOptions loadOptions = new LoadOptions(LoadFormat.CSV);
            Workbook newWorkbook = new Workbook(TextFile, loadOptions);

            newWorkbook.Save(fileName);
        }
开发者ID:assadvirgo,项目名称:Aspose_Cells_NET,代码行数:7,代码来源:Program.cs

示例3: LoadItem

        protected override Item LoadItem(Item item, LoadOptions options)
        {
            Assert.ArgumentNotNull(item, "item");

            var itemData = new ItemData(item);

            var configuration = _helper.GetConfigurationForItem(itemData);

            if (configuration == null) return base.LoadItem(item, options);

            var sourceStore = configuration.Resolve<ISourceDataStore>();
            var targetStore = configuration.Resolve<ITargetDataStore>();

            var targetItem = targetStore.GetByPathAndId(itemData.Path, itemData.Id, itemData.DatabaseName);

            if (targetItem == null)
            {
                Log.Warn("Unicorn: Unable to load item because it was not serialized.", this);
                return base.LoadItem(item, options);
            }

            sourceStore.Save(targetItem);

            return Database.GetItem(item.Uri);
        }
开发者ID:ramnkl,项目名称:Unicorn,代码行数:25,代码来源:UnicornLoadItemCommand.cs

示例4: GetForKey

        public static ApprovalStatus GetForKey(String code, LoadOptions options)
        {
            ApprovalStatus status = null;

            if (options == LoadOptions.DiskOnly)
            {
                status = ShortSaleSchemaSession.GetContext().ApprovalStatus.Single(o => o.Code == code);
                cache[code] = status;
            }
            else
            {
                try
                {
                    status = cache[code];
                }
                catch (KeyNotFoundException ex)
                {
                    if (options == LoadOptions.CacheFirst)
                    {
                        status = ShortSaleSchemaSession.GetContext().ApprovalStatus.Single(o => o.Code == code);
                        cache[code] = status;
                    }
                    else
                    {
                        throw ex;
                    }
                }
            }
            return status;
        }
开发者ID:heimanhon,项目名称:researchwork,代码行数:30,代码来源:ApprovalStatus.cs

示例5: ToXDocument

 /// <summary>
 /// Converts XmlDocument to XDocument using load options.
 /// </summary>
 /// <param name="document">
 /// The input document to be converted.
 /// </param>
 /// <param name="options">
 /// The options for the conversion.
 /// </param>
 /// <returns>
 /// Resulting XDocument.
 /// </returns>
 public static XDocument ToXDocument(this XmlDocument document, LoadOptions options)
 {
     using (XmlNodeReader reader = new XmlNodeReader(document))
     {
         return XDocument.Load(reader, options);
     }
 }
开发者ID:chien-andalou,项目名称:QuickRoutes,代码行数:19,代码来源:XmlDocumentExtensions.cs

示例6: ConvertToRtfPwd

 public bool ConvertToRtfPwd(string source, string target, string password)
 {
     LoadOptions lo = new LoadOptions(password);
     Document doc = new Document(source, lo);
     doc.Save(target, SaveFormat.Rtf);
     return true;
 }
开发者ID:killbug2004,项目名称:WSProf,代码行数:7,代码来源:AsposeConverter.cs

示例7: Main

        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Aspose.Cells.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            string sampleFile = "Sample.out.xlsx";
            string samplePath = dataDir + sampleFile;

            // Create a sample workbook
            // and put some data in first cell of all 3 sheets
            Workbook createWorkbook = new Workbook();
            createWorkbook.Worksheets["Sheet1"].Cells["A1"].Value = "Aspose";
            createWorkbook.Worksheets.Add("Sheet2").Cells["A1"].Value = "Aspose";
            createWorkbook.Worksheets.Add("Sheet3").Cells["A1"].Value = "Aspose";
            createWorkbook.Worksheets["Sheet3"].IsVisible = false;
            createWorkbook.Save(samplePath);

            // Load the sample workbook
            LoadDataOption loadDataOption = new LoadDataOption();
            loadDataOption.OnlyVisibleWorksheet = true;
            LoadOptions loadOptions = new LoadOptions();
            loadOptions.LoadDataAndFormatting = true;
            loadOptions.LoadDataOptions = loadDataOption;

            Workbook loadWorkbook = new Workbook(samplePath, loadOptions);
            Console.WriteLine("Sheet1: A1: {0}", loadWorkbook.Worksheets["Sheet1"].Cells["A1"].Value);
            Console.WriteLine("Sheet1: A2: {0}", loadWorkbook.Worksheets["Sheet2"].Cells["A1"].Value);
            Console.WriteLine("Sheet1: A3: {0}", loadWorkbook.Worksheets["Sheet3"].Cells["A1"].Value);
        }
开发者ID:nesterenes,项目名称:Aspose_Cells_NET,代码行数:28,代码来源:LoadVisibleSheetsOnly.cs

示例8: Run

        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
            // Define a new Workbook.
            Workbook workbook;

            // Set the load data option with selected sheet(s).
            LoadDataOption dataOption = new LoadDataOption();
            dataOption.SheetNames = new string[] { "Sheet2" };

            // Load the workbook with the spcified worksheet only.
            LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
            loadOptions.LoadDataOptions = dataOption;
            loadOptions.LoadDataAndFormatting = true;

            // Creat the workbook.
            workbook = new Workbook(dataDir+ "TestData.xlsx", loadOptions);

            // Perform your desired task.

            // Save the workbook.
            workbook.Save(dataDir+ "outputFile.out.xlsx");
            // ExEnd:1
            
        }
开发者ID:aspose-cells,项目名称:Aspose.Cells-for-.NET,代码行数:27,代码来源:LoadSpecificSheets.cs

示例9: Run

        public static void Run() 
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create a sample workbook and add some data inside the first worksheet
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            worksheet.Cells["P30"].PutValue("This is sample data.");

            // Save the workbook in memory stream
            MemoryStream ms = new MemoryStream();
            workbook.Save(ms, SaveFormat.Xlsx);
            ms.Position = 0;

            // Now load the workbook from memory stream with A5 paper size
            LoadOptions opts = new LoadOptions(LoadFormat.Xlsx);
            opts.SetPaperSize(PaperSizeType.PaperA5);
            workbook = new Workbook(ms, opts);

            // Save the workbook in pdf format
            workbook.Save(dataDir + "LoadWorkbookWithPrinterSize-a5_out.pdf");

            // Now load the workbook again from memory stream with A3 paper size
            ms.Position = 0;
            opts = new LoadOptions(LoadFormat.Xlsx);
            opts.SetPaperSize(PaperSizeType.PaperA3);
            workbook = new Workbook(ms, opts);

            // Save the workbook in pdf format
            workbook.Save(dataDir + "LoadWorkbookWithPrinterSize-a3_out.pdf");
            // ExEnd:1          
        }
开发者ID:aspose-cells,项目名称:Aspose.Cells-for-.NET,代码行数:34,代码来源:LoadWorkbookWithPrinterSize.cs

示例10: Run

        public static void Run()
        {
            // ExStart:LoadWorkbookWithSpecificCultureInfoDateFormat
            using (var inputStream = new MemoryStream())
            {
                using (var writer = new StreamWriter(inputStream))
                {
                    writer.WriteLine("<html><head><title>Test Culture</title></head><body><table><tr><td>10-01-2016</td></tr></table></body></html>");
                    writer.Flush();

                    var culture = new CultureInfo("en-GB");
                    culture.NumberFormat.NumberDecimalSeparator = ",";
                    culture.DateTimeFormat.DateSeparator = "-";
                    culture.DateTimeFormat.ShortDatePattern = "dd-MM-yyyy";
                    LoadOptions options = new LoadOptions(LoadFormat.Html);
                    options.CultureInfo = culture;

                    using (var workbook = new Workbook(inputStream, options))
                    {
                        var cell = workbook.Worksheets[0].Cells["A1"];
                        Assert.AreEqual(CellValueType.IsDateTime, cell.Type);
                        Assert.AreEqual(new DateTime(2016, 1, 10), cell.DateTimeValue);
                    }
                }
            }
            // ExEnd:LoadWorkbookWithSpecificCultureInfoDateFormat
        }
开发者ID:aspose-cells,项目名称:Aspose.Cells-for-.NET,代码行数:27,代码来源:LoadWorkbookWithSpecificCultureInfoDateFormat.cs

示例11: Run

        public static void Run()
        {
            // ExStart:ReadVisioDiagram
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_LoadSaveConvert();

            // Call the diagram constructor to load a VSD stream
            FileStream st = new FileStream(dataDir + "Drawing1.vsdx", FileMode.Open);
            Diagram vsdDiagram = new Diagram(st);
            st.Close();

            // Call the diagram constructor to load a VDX diagram
            Diagram vdxDiagram = new Diagram(dataDir + "Drawing1.vdx");

            /*
             * Call diagram constructor to load a VSS stencil
             * providing load file format
            */
            Diagram vssDiagram = new Diagram(dataDir + "Basic.vss", LoadFileFormat.VSS);

            /*
             * Call diagram constructor to load diagram from a VSX file
             * providing load options
            */
            LoadOptions loadOptions = new LoadOptions(LoadFileFormat.VSX);
            Diagram vsxDiagram = new Diagram(dataDir + "Drawing1.vsx", loadOptions);
            // ExEnd:ReadVisioDiagram
        }
开发者ID:aspose-diagram,项目名称:Aspose.Diagram-for-.NET,代码行数:28,代码来源:ReadVisioDiagram.cs

示例12: ToXDocument

 public static XDocument ToXDocument(this XmlDocument xmlDocument, LoadOptions options = LoadOptions.None)
 {
     using (var nodeReader = new XmlNodeReader(xmlDocument))
     {
         nodeReader.MoveToContent();
         return XDocument.Load(nodeReader, options);
     }
 }
开发者ID:erashid,项目名称:Extensions,代码行数:8,代码来源:XmlDocumentExtension.cs

示例13: ConvertToDocPwd

 public bool ConvertToDocPwd(string source, string target, string password)
 {
     // TODO: Add logging
     LoadOptions lo = new LoadOptions(password);
     Document document = new Document(source, lo);
     document.Save(target, SaveFormat.Doc);
     return true;
 }
开发者ID:killbug2004,项目名称:WSProf,代码行数:8,代码来源:AsposeConverter.cs

示例14: DeserializeDatabase

 private static void DeserializeDatabase(bool force)
 {
     foreach (string path2 in Factory.GetDatabaseNames())
       {
     var options = new LoadOptions { ForceUpdate = force, DisableEvents = true };
     Manager.LoadTree(Path.Combine(PathUtils.Root, path2), options);
       }
 }
开发者ID:WSlama,项目名称:Sitecore-Mobile-Device-Detector,代码行数:8,代码来源:Deserialize.aspx.cs

示例15: XmlActionResult

 public XmlActionResult(string xml, string fileName,
     EncodingType encoding = EncodingType.UTF8,
     LoadOptions loadOptions = System.Xml.Linq.LoadOptions.None)
 {
     XmlContent = xml;
     FileName = fileName;
     Encoding = encoding;
     LoadOptions = loadOptions;
 }
开发者ID:sabotuer99,项目名称:ExtensibilityMVC,代码行数:9,代码来源:XmlActionResult.cs


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