Esempio n. 1
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            List <string> list = new List <string>();

            Excel.Application appExcel   = new Excel.Application();
            Excel.Workbooks   workBooks  = appExcel.Workbooks;
            Excel.Workbook    excelSheet = workBooks.Open(@path, false, ReadOnly: true);

            foreach (Excel.Worksheet worksheet1 in excelSheet.Worksheets)
            {
                Excel.Hyperlinks hyperLinks = worksheet1.Hyperlinks;
                foreach (Excel.Hyperlink lin in hyperLinks)
                {
                    list.Add(lin.Address);
                }
            }
            @path2 += @"\res.xlsx";
            Workbook  workbook  = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            for (int i = 1; i < list.Count() + 1; i++)
            {
                string            el   = "A" + i.ToString();
                Aspose.Cells.Cell cell = worksheet.Cells[el];
                int index = worksheet.Hyperlinks.Add(el, 1, 1, list[i - 1]);
                worksheet.Hyperlinks[index].TextToDisplay = list[i - 1];
                worksheet.Hyperlinks[index].ScreenTip     = list[i - 1];
            }
            workbook.Save(@path2);
            MessageBox.Show("Succesfull");
        }
Esempio n. 2
0
        private ICollection <FileInfo> GetHyperLinksWorkSheet(Excel.Worksheet worksheet)
        {
            List <FileInfo> attachments = new List <FileInfo>();

            Excel.Hyperlinks links = worksheet.Hyperlinks;
            foreach (Excel.Hyperlink link in links)
            {
                if (link.Address != null)
                {
                    String archivo = link.Address;
                    if (archivo != null && isFile(archivo))
                    {
                        attachments.Add(this.GetLinkFile(archivo));
                    }
                }
            }
            return(attachments);
        }