• 大小: 1.38MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-08-17
  • 语言: C#
  • 标签: c#  oracle  excel  aspose  

资源简介

c#全部源码,用到了aspose插件。 能将查询导出到excel。 能一次导出多条查询语句,语句需要用";"分割。 自动判断数据条数分页,每页65535条。 自动判断导出文件大小,若单文件大于100MB,则分文件导出

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
//using System.ComponentModel;
using System.Text.Regularexpressions;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Microsoft.Win32;
using System.Collections;
using Aspose.Cells;
using System.Data.OracleClient;

namespace orcl2xls
{

    public partial class Form_Main : Form
    {
        public Form_Main()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {
            //声明一个注册表项对象,使其打开LocalMachine主项
            RegistryKey HKEY = Registry.LocalMachine;

            //声明另外一个注册表项对象,使其打开Oracle所用到的项
            RegistryKey OracleSubKey = HKEY.OpenSubKey(@“Software\oracle\“ false);

            //然后用GetValue方法,得到Oracle安装文件夹的路径
            string tnsFileName = ““;
            try
            {
                tnsFileName = OracleSubKey.GetValue(“ORACLE_HOME“).ToString();
            }
            catch
            {
                if (OracleSubKey != null)
                {
                    string[] subkeyNames;
                    subkeyNames = OracleSubKey.GetSubKeyNames();
                    foreach (string keyName in subkeyNames)
                    {
                        RegistryKey OracleSubSubKey = HKEY.OpenSubKey(@“Software\oracle\“ + keyName false);
                        try
                        {
                            tnsFileName = OracleSubSubKey.GetValue(“ORACLE_HOME“).ToString();
                        }
                        catch
                        {
                        }
                        if (tnsFileName != ““)
                            break;
                    }


                }

            }
            if (tnsFileName != ““)
            {
                //得到Oracle连接串配置文件的绝对地址
                tnsFileName += @“\network\ADMIN\tnsnames.ora“;

                //声明一个StreamReader对象,打开这个配置文件
                StreamReader fin = new StreamReader(tnsFileName);
                string Content TnsContent TmpName;
                O2F.TnsList.Clear();
                TnsContent = ““;
                TmpName = ““;
                Content = fin.ReadLine();    //从配置文件里读一行数据
                while (Content != null)    //执行循环,直到读取的内容为null,退出循环
                {
                    //再读一行,因为配置文件里前两行都是注释,所以不加限制的读取3行是没有问题的
                    Content = fin.ReadLine();
                    //Content = Content.Trim();
                    //判断读取的内容是不是符合条件。
                    //由于&&判断是骤死式判断,所以当&&前的判断不成立时,后面的判断就不进行了。
                    //所以按照这个顺序写,是不会出错的。
                    //如果把Content!=null放到if判断的第二条,那么程序就会出错(因为当读到文件尾的时候,Content会等于null)
                    if (Content != null && Content.Trim().Length != 0 && Content.Trim()[0] != ‘#‘)//&& Content[0] != ‘#‘ && Content[0] != ‘(‘ && Content[0] != ‘)‘)
                    {
                        

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件    4317184  2014-09-18 09:08  orcl2xls\orcl2xls\bin\Release\Aspose.Cells.dll

     文件        427  2014-09-18 09:09  orcl2xls\orcl2xls\bin\Release\License.lic

     文件      53248  2014-09-23 11:53  orcl2xls\orcl2xls\bin\Release\orcl2xls.exe

     文件      36352  2014-09-23 11:53  orcl2xls\orcl2xls\bin\Release\orcl2xls.pdb

     文件      16958  2014-09-19 08:32  orcl2xls\orcl2xls\bin\Release\OTE.ico

     文件      42748  2014-09-23 11:53  orcl2xls\orcl2xls\Form1.cs

     文件      11553  2014-09-22 15:42  orcl2xls\orcl2xls\Form1.Designer.cs

     文件       6431  2014-09-22 15:42  orcl2xls\orcl2xls\Form1.resx

     文件        842  2014-09-22 16:47  orcl2xls\orcl2xls\obj\Debug\orcl2xls.csproj.GenerateResource.Cache

     文件      53248  2014-09-22 16:48  orcl2xls\orcl2xls\obj\Debug\orcl2xls.exe

     文件        180  2014-09-16 22:28  orcl2xls\orcl2xls\obj\Debug\orcl2xls.Form_Login.resources

     文件        180  2014-09-22 16:47  orcl2xls\orcl2xls\obj\Debug\orcl2xls.Form_Main.resources

     文件      46592  2014-09-22 16:48  orcl2xls\orcl2xls\obj\Debug\orcl2xls.pdb

     文件        180  2014-09-18 16:49  orcl2xls\orcl2xls\obj\Debug\orcl2xls.Properties.Resources.resources

     文件        295  2014-09-21 22:52  orcl2xls\orcl2xls\obj\orcl2xls.csproj.FileList.txt

     文件       1707  2014-09-23 11:53  orcl2xls\orcl2xls\obj\orcl2xls.csproj.FileListAbsolute.txt

     文件        842  2014-09-23 11:53  orcl2xls\orcl2xls\obj\Release\orcl2xls.csproj.GenerateResource.Cache

     文件      53248  2014-09-23 11:53  orcl2xls\orcl2xls\obj\Release\orcl2xls.exe

     文件        180  2014-09-23 11:53  orcl2xls\orcl2xls\obj\Release\orcl2xls.Form_Main.resources

     文件      36352  2014-09-23 11:53  orcl2xls\orcl2xls\obj\Release\orcl2xls.pdb

     文件        180  2014-09-23 11:53  orcl2xls\orcl2xls\obj\Release\orcl2xls.Properties.Resources.resources

     文件       3528  2014-09-23 08:53  orcl2xls\orcl2xls\orcl2xls.csproj

     文件      16958  2014-09-19 08:33  orcl2xls\orcl2xls\OTE.ico

     文件        471  2014-09-17 08:36  orcl2xls\orcl2xls\Program.cs

     文件       1176  2014-09-19 09:28  orcl2xls\orcl2xls\Properties\AssemblyInfo.cs

     文件       2870  2014-09-16 22:16  orcl2xls\orcl2xls\Properties\Resources.Designer.cs

     文件       5350  2014-09-16 22:16  orcl2xls\orcl2xls\Properties\Resources.resx

     文件       1091  2014-09-16 22:16  orcl2xls\orcl2xls\Properties\Settings.Designer.cs

     文件        249  2014-09-16 22:16  orcl2xls\orcl2xls\Properties\Settings.settings

     文件        917  2014-09-17 00:10  orcl2xls\orcl2xls.sln

............此处省略16个文件信息

评论

共有 条评论