Example #1
0
        private void writeHyperLinks_Click(object sender, System.EventArgs e)
        {
            if (Xls == null)
            {
                MessageBox.Show("You need to open a file first.");
                return;
            }

            ExcelFile XlsOut = new XlsFile(true);

            XlsOut.NewFile(1, TExcelFileFormat.v2019);

            for (int i = 1; i <= Xls.HyperLinkCount; i++)
            {
                TXlsCellRange Range = Xls.GetHyperLinkCellRange(i);
                THyperLink    HLink = Xls.GetHyperLink(i);

                int    XF    = -1;
                object Value = Xls.GetCellValue(Range.Top, Range.Left, ref XF);
                XlsOut.SetCellValue(i, 1, Value, XlsOut.AddFormat(Xls.GetFormat(XF)));
                XlsOut.AddHyperLink(new TXlsCellRange(i, 1, i, 1), HLink);
            }

            if (saveFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            XlsOut.Save(saveFileDialog1.FileName);
            if (MessageBox.Show("Do you want to open the generated file?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                Process.Start(saveFileDialog1.FileName);
            }
        }