Exemplo n.º 1
0
        private void button1_Click(object sender, RibbonControlEventArgs e)
        {
            var selectedRange = LatexTable.Globals.ThisAddIn.Application.Selection as Microsoft.Office.Interop.Excel.Range;
            var selectedAreas = selectedRange.Areas as Microsoft.Office.Interop.Excel.Areas;

            bool enable_hide_skip = skipHidden.Checked;

            RangeConvert rc  = new RangeConvert(selectedAreas[1], enable_hide_skip);
            Tabular      tab = new Tabular(rc);
            Table        tb  = new Table();

            tb.has_centering   = enableCentering.Checked;
            tb.has_caption     = hasCaption.Checked;
            tb.caption_content = Caption.Text;

            tb.has_label     = hasLabel.Checked;
            tb.label_content = Label.Text;

            tb.resize   = fitWidth.Checked;
            tb.position = position.Text;


            Clipboard.SetText(string.Join("\n", tb.Create_table(tab)));
            // MessageBox.Show(tb_buff);
        }
Exemplo n.º 2
0
        } // Create_table

        public List <string> Create_table(Tabular tab)
        {
            List <string> tb_list = new List <string>();

            // Head
            tb_list.Add(table_head);

            // Add Centering
            if (has_centering)
            {
                tb_list.Add(indent + centering);
            }

            // Add Caption
            if (has_caption)
            {
                tb_list.Add(indent + caption);
            }

            // Add Label
            if (has_label)
            {
                tb_list.Add(indent + label);
            }

            // Resize Head
            if (resize)
            {
                tb_list.Add(indent + resize_head);
            }

            // Contents Lines
            foreach (string line in tab.Create_tabular())
            {
                // インデントを足してcontents lineを内部に展開
                tb_list.Add(indent + line);
            }


            // Resize Foot
            if (resize)
            {
                tb_list.Add(indent + resize_foot);
            }

            // Foot
            tb_list.Add(table_foot);

            return(tb_list);
        } // Create_table
Exemplo n.º 3
0
        private void SaveFileButton_Click(object sender, RibbonControlEventArgs e)
        {
            var selectedRange = LatexTable.Globals.ThisAddIn.Application.Selection as Microsoft.Office.Interop.Excel.Range;
            var selectedAreas = selectedRange.Areas as Microsoft.Office.Interop.Excel.Areas;

            bool enable_hide_skip = !skipHidden.Checked;

            RangeConvert rc  = new RangeConvert(selectedAreas[1], enable_hide_skip);
            Tabular      tab = new Tabular(rc);
            Table        tb  = new Table()
            {
                has_centering   = enableCentering.Checked,
                has_caption     = hasCaption.Checked,
                caption_content = Caption.Text,
                has_label       = hasLabel.Checked,
                label_content   = Label.Text,
                resize          = fitWidth.Checked,
                position        = position.Text
            };

            // Generate SaveFileDialog
            SaveFileDialog sa = new SaveFileDialog();

            sa.Title       = "Save Table as File";
            sa.FileName    = @"table.tex";
            sa.Filter      = "Latex File(*.tex)|*.tex|All Files(*.*)|*.*";
            sa.FilterIndex = 1;

            // Show Dialog
            DialogResult result = sa.ShowDialog();

            if (result == DialogResult.OK)
            {
                string fileName = sa.FileName;
                var    writer   = new System.IO.StreamWriter(fileName, false);
                writer.WriteLine(string.Join("\n", tb.Create_table(tab)));
                writer.Close();
            }
            else if (result == DialogResult.Cancel)
            {
            }
        }