Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Excel;
Expand Down Expand Up @@ -107,7 +108,14 @@ private void CopyFromMarkdown(CommandBarButton ctrl, ref bool canceldefault)
{
var cell = row[j];
var activeSheetCell = (Range)activeSheet.Cells[range.Row + i, range.Column + j];
activeSheetCell.Value2 = cell.Value
var value = cell.Value;
var match = Regex.Match(value, "\\[([^\\]]+)\\]\\(([^\\)]+)\\)");
if (match.Success)
{
activeSheet.Hyperlinks.Add(activeSheetCell, match.Groups[2].Value);
value = value.Replace(match.Value, match.Groups[1].Value);
}
activeSheetCell.Value2 = value
.Replace("<br>", "\n")
.Replace("<br/>", "\n")
.Replace("&#124;", "|");
Expand Down Expand Up @@ -170,7 +178,15 @@ private void CopyToMarkdown(CommandBarButton ctrl, ref bool cancelDefault)
var cell = (Range)range.Cells[1, x];

resultBuffer.Append("|");
resultBuffer.Append(cell.FormatText());
if (cell.Hyperlinks.Count > 0)
{
resultBuffer.Append("[").Append(cell.FormatText()).Append("]")
.Append("(").Append(cell.Hyperlinks[1].Address).Append(")");
}
else
{
resultBuffer.Append(cell.FormatText());
}
switch ((int)cell.HorizontalAlignment)
{
case AlignmentLeft:
Expand Down Expand Up @@ -202,7 +218,15 @@ private void CopyToMarkdown(CommandBarButton ctrl, ref bool cancelDefault)
var cell = (Range)range.Cells[y, x];

resultBuffer.Append("|");
resultBuffer.Append(cell.FormatText());
if (cell.Hyperlinks.Count > 0)
{
resultBuffer.Append("[").Append(cell.FormatText()).Append("]")
.Append("(").Append(cell.Hyperlinks[1].Address).Append(")");
}
else
{
resultBuffer.Append(cell.FormatText());
}
}
resultBuffer.Append("|");
resultBuffer.Append(Environment.NewLine);
Expand Down