OpenOffice의 하이퍼링크에서 텍스트와 링크 분리

OpenOffice의 하이퍼링크에서 텍스트와 링크 분리

OpenOffice 스프레드시트로 변환된 북마크 목록이 있습니다. 이제 링크 URL(아래 파란색)과 해당 텍스트(검은색)를 두 개의 열로 분리하고 싶습니다.

영상

이를 달성할 수 있는 방법이 있나요?

답변1

핵심은 OpenOffice.org Calc의 텍스트 가져오기 기능을 사용하는 것입니다.

사용된 정확한 형식을 확인하기 위해 북마크 사본이 ​​없으면 특정 형식에 맞게 조정해야 할 수 있는 일반적인 지침을 제공하겠습니다.

이 작업을 수행하는 가장 쉬운 방법은 텍스트 편집기에서 북마크 목록을 열고 전체 파일을 클립보드에 복사하는 것입니다.

이제 OpenOffice.org Calc에서 새 스프레드시트를 만듭니다.

OpenOffice.org에서 다음을 누릅니다.Ctrl+Shift+V수행하다선택하여 붙여넣기행동. 클립보드를 서식 없는 텍스트로 가져오도록 지정하면 텍스트 가져오기 대화 상자가 표시됩니다.

텍스트 가져오기 대화 상자

해당 대화 상자에서다음으로 구분됨라디오 버튼. 소스 데이터의 정확한 형식에 따라 아래 확인란을 조정하세요.다음으로 구분됨링크 URL을 텍스트에서 올바르게 분리합니다. 문제가 있는 경우 오른쪽에 있는 텍스트 필드에 다른 문자를 입력할 수 있습니다.다른체크박스. 슬래시(/)를 해당 텍스트 필드에 입력하면 다음으로 시작하는 모든 URL이 검색됩니다.http://그리고https://그리고 그것들을 자신의 열에 넣으세요.

답변2

그것은 추출하는 직접적인 기능을 놓친 것 같기 때문에하이퍼링크텍스트에서매크로그것은 단지 존재합니다. 답변 하단에서 CELL_URL(SheetNumber,Row,Column)하이퍼링크 값을 반환할 수 있는 함수를 정의하는 코드를 찾을 수 있습니다. 그런 다음 해당 매크로를 추가하면 해당 기능을 사용할 수 있습니다 CELL_URL(지침 아래).

간단한 솔루션.그림의 예에 따라 셀 B90=CELL_URL(1,ROW(A90),1). 그러면 B90셀의 링크 에 기록되고 A90, 그렇지 않으면 아무것도 기록되지 않습니다. 셀에서 텍스트만 포함하도록 C90간단히 작성할 수 있습니다 (=A90하이퍼링크). 그래서 텍스트를 분할하고하이퍼링크. 그런 다음 이러한 셀( B90C90)을 복사하여 모든 열 BC, 또는 필요한 모든 행에 붙여넣을 수 있습니다. 귀하의 예에서는
A이 고정되어 있으며 이를 위해 제가 썼습니다 =CELL_URL(...,1). 필요한 경우 다른 열 번호를 지정하거나 다른 열에서 이 함수를 호출할 수 있습니다.시트.

확장된 솔루션.단순히 텍스트를 분할하고 짝수 셀(2,4,6...)의 하이퍼링크를 원하는지 아니면 홀수 셀(3,5,...)을 올리려는지 (나에게는) 불분명했기 때문에 ) 내용이 짝수에 가깝기 때문에 열에 B텍스트, 주소 CDURL을 제공하는 다음 스키마를 제안합니다. 한 줄은 열에 채워지고 , B한 줄은 비어 있습니다. (복사한 후 값을 다른 곳에 붙여넣으세요.CD시트빈 줄을 건너뛰도록 재정렬하거나 다른 함수의 매개변수로 더 복잡한 방정식을 직접 추가할 수 있습니다.시트).

1일에 근무하시는 것 같아요시트~의계산, 텍스트는 A행 2부터 시작하는 열에 있으므로 A2첫 번째 경우가 있습니다. 그렇지 않은 경우숫자를 바꾸다예를 들어 A2에서 A20으로, A3에서 A21로, B2에서 B20으로...

  • B2=IF(D2="","",A2).
  • 셀에 C2쓰기=IF(D2="","",A3)
  • 셀에 D2쓰기=CELL_URL(1,ROW(A2),1)

세 개의 셀을 복사하여 필요한 곳에 붙여넣습니다.
논리는 다음과 같습니다. 링크를 추출할 수 있으면( 채워짐) 다른 열( 및 ) D을 씁니다 .BC

매크로를 추가하는 방법

Tools->Macro->Organize Macros->Open/Libre Office Basic작업 중인 시트에서 이동하여새로운매크로. 당신이 좋아하는 이름을 지어주세요. 새 창이 열리는 것을 볼 수 있습니다. 코드를 복사하여 붙여넣으세요.


매크로

REM  *****  BASIC  *****
REM ################### RETURNING STRING #################################################
Function CELL_NOTE(vSheet,lRowIndex&,iColIndex%)
'calls: getSheetCell
REM returns annotation text
Dim v
   v = getSheetCell(vSheet,lRowIndex&,iColIndex%)
   if vartype(v) = 9 then
      CELL_NOTE = v.Annotation.getText.getString
   else
      CELL_NOTE = v
   endif
End Function
Function CELL_URL(vSheet,lRowIndex&,iColIndex%,optional n%)
'calls: getSheetCell
REM returns URL of Nth text-hyperlink from a cell, default N=1)
Dim v
   If isMissing(n) then n= 1
   If n < 1 then
      CELL_URL = Null
      exit function
   endif
   v = getSheetCell(vSheet,lRowIndex&,iColIndex%)
   if vartype(v) = 9 then
      if v.Textfields.Count >= n  then 
         CELL_URL = v.getTextfields.getByIndex(n -1).URL 
      else
         Cell_URL = Null
      endif
   else
      CELL_URL = v
   endif
End Function
Function CELL_FORMULA(vSheet,lRowIndex&,iColIndex%)
'calls: getSheetCell
REM return unlocalized (English) formula
Dim v
   v = getSheetCell(vSheet,lRowIndex&,iColIndex%)
   if vartype(v) = 9 then
      CELL_FORMULA = v.getFormula()
   else
      CELL_FORMULA = v
   endif
End Function
Function CELL_STYLE(vSheet,lRowIndex&,iColIndex%,optional bLocalized)
'calls: getSheetCell
REM return name of cell-style, optionally localized
Dim v,s$,bLocal as Boolean
   if not isMissing(bLocalized) then bLocal=cBool(bLocalized)
   v = getSheetCell(vSheet,lRowIndex&,iColIndex%)
   if vartype(v) = 9 then
      if bLocal then
         s = thisComponent.StyleFamilies("CellStyles").getByName(v.CellStyle).DisplayName
      else
         s = v.CellStyle
      endif
      CELL_STYLE = s
   else
      CELL_STYLE = v
   endif
End Function
Function CELL_LINE(vSheet,lRowIndex&,iColIndex%,optional n)
'calls: getSheetCell
REM Split by line breaks, missing or zero line number returns whole string.
REM =CELL_LINE(SHEET(),1,1,2) -> second line of A1 in this sheet
Dim v,s$,a(),i%
   v = getSheetCell(vSheet,lRowIndex&,iColIndex%)
   if vartype(v) = 9 then
      s = v.getString
      if not isMissing(n) then i = cInt(n)
      if i > 0 then
         a() = Split(s,chr(10))
         If (i <= uBound(a())+1)then
            CELL_LINE = a(i -1)
         else
            CELL_LINE = NULL
         endif
      else
         CELL_LINE = s
      endif
   else
      CELL_LINE = v
   endif
end Function

REM ################### RETURNING NUMBER #################################################
Function CELL_ISHORIZONTALPAGEBREAK(vSheet,lRowIndex&,iColIndex%)
'calls: getSheetCell
Dim v
   v = getSheetCell(vSheet,lRowIndex&,iColIndex%)
   if vartype(v) = 9 then
      CELL_ISHORIZONTALPAGEBREAK = Abs(cINT(v.Rows.getByIndex(0).IsStartOfNewPage))
   else
      CELL_ISHORIZONTALPAGEBREAK = v
   endif
End Function
Function CELL_ISVERTICALPAGEBREAK(vSheet,lRowIndex&,iColIndex%)
'calls: getSheetCell
Dim v
   v = getSheetCell(vSheet,lRowIndex&,iColIndex%)
   if vartype(v) = 9 then
      CELL_ISVERTICALPAGEBREAK = Abs(cINT(v.Columns.getByIndex(0).IsStartOfNewPage))
   else
      CELL_ISVERTICALPAGEBREAK = v
   endif
End Function
Function CELL_CHARCOLOR(vSheet,lRowIndex&,iColIndex%)
'calls: getSheetCell
REM returns color code as number
Dim v
   v = getSheetCell(vSheet,lRowIndex&,iColIndex%)
   if vartype(v) = 9 then
      CELL_CHARCOLOR = v.CharColor
   else
      CELL_CHARCOLOR = v
   endif
End Function
Function CELL_BACKCOLOR(vSheet,lRowIndex&,iColIndex%)
'calls: getSheetCell
REM returns color code as number
Dim v
   v = getSheetCell(vSheet,lRowIndex&,iColIndex%)
   if vartype(v) = 9 then
      CELL_BACKCOLOR = v.CellBackColor
   else
      CELL_BACKCOLOR = v
   endif
End Function
Function CELL_VISIBLE(vSheet,lRowIndex&,iColIndex%)
'calls: getSheetCell
REM returns visibility state as number 0|1
Dim v
   v = getSheetCell(vSheet,lRowIndex&,iColIndex%)
   if vartype(v) = 9 then
      CELL_VISIBLE = Abs(v.Rows.isVisible)
   else
      CELL_VISIBLE = v
   endif
End Function
Function CELL_LOCKED(vSheet,lRowIndex&,iColIndex%)
'calls: getSheetCell
REM returns locked state as number 0|1
Dim v
   v = getSheetCell(vSheet,lRowIndex&,iColIndex%)
   if vartype(v) = 9 then
      CELL_LOCKED = Abs(v.CellProtection.isLocked)
   else
      CELL_LOCKED = v
   endif
End Function
Function CELL_NumberFormat(vSheet,lRowIndex&,iColIndex%)
'calls: getSheetCell
REM returns the number format index
Dim v
   v = getSheetCell(vSheet,lRowIndex&,iColIndex%)
   if vartype(v) = 9 then
      CELL_NumberFormat = v.NumberFormat
   else
      CELL_NumberFormat = v
   endif
End Function
Function CELL_NumberFormatType(vSheet,lRowIndex&,iColIndex%)
'calls: getSheetCell
REM return a numeric com.sun.star.util.NumberFormat which describes a format category
Dim v,lNF&
   v = getSheetCell(vSheet,lRowIndex&,iColIndex%)
   if vartype(v) = 9 then
      lNF = v.NumberFormat
      CELL_NumberFormatType = ThisComponent.getNumberFormats.getByKey(lNF).Type
   else
      CELL_NumberFormatType = v
   endif
End Function

'################### HELPERS FOR ABOVE CELL FUNCTIONS #########################################
Function getSheet(byVal vSheet)
REM Helper for sheet functions. Get cell from sheet's name or position; cell's row-position; cell's col-position
on error goto exitErr
   select case varType(vSheet)
   case is = 8
      if thisComponent.sheets.hasbyName(vSheet) then
         getSheet = thisComponent.sheets.getByName(vSheet)
      else
         getSheet = NULL
      endif
   case 2 to 5
      vSheet = cInt(vSheet)
      'Wow! Calc has sheets with no name at index < 0,
      ' so NOT isNull(oSheet), if vSheet <= lbound(sheets) = CRASH!
      'http://www.openoffice.org/issues/show_bug.cgi?id=58796
      if(vSheet <= thisComponent.getSheets.getCount)AND(vSheet > 0) then
         getSheet = thisComponent.sheets.getByIndex(vSheet -1)
      else
         getSheet = NULL
      endif
   end select
exit function
exitErr:
getSheet = NULL
End Function

Function getSheetCell(byVal vSheet,byVal lRowIndex&,byVal iColIndex%)
dim oSheet
'   print vartype(vsheet)
   oSheet = getSheet(vSheet)
   if varType(oSheet) <>9 then
      getSheetCell = NULL
   elseif (lRowIndex > oSheet.rows.count)OR(lRowIndex < 1) then
      getSheetCell = NULL
   elseif (iColIndex > oSheet.columns.count)OR(iColIndex < 1) then
      getSheetCell = NULL
   else
      getSheetCell = oSheet.getCellByPosition(iColIndex -1,lRowIndex -1)
   endif
End Function

참고자료:

  • 내성적인 세포 기능, 오픈오피스 포럼에서.
  • 또 다른답변StackOverflow에서.
  • 더 나아가독서전문가 교환에.
  • 더 나아가영감Ubuntu 포럼에서 자신만의 매크로 작성을 시작해 보세요.

작업리브레오피스버전: 4.2.8.2.

답변3

저는 OpenOffice calc 사용자는 아니지만 다른 복잡한 답변을 고려하여 더 간단한 솔루션(작동할 수도 있음)을 제공하려고 노력할 것입니다.

내가 올바르게 이해했다면 현재 A1, A3, A5 등에 링크가 있는 텍스트가 포함되고 A2, A4, A6 등에 간단한 텍스트가 포함된 1열 스프레드시트가 있는 것입니다.

다음과 같이 새 스프레드시트를 구성하고 싶습니다.

A1 , A2  
A3 , A4  
A5 , A6  
etc.

=MOD(ROW();2)내 생각은 전체 B 열에 전파되는 수식을 사용하여 B1 열을 추가하는 것입니다 . 그러면 다음이 제공됩니다.

A1 , 1
A2 , 0
A3 , 1
A4 , 0
etc.

이제 B열을 기준으로 정렬(또는 필요에 따라 정렬이 작동하지 않는 경우 필터링)하여 모든 열을 함께 집계합니다.

A1 , 1
A3 , 1
etc.
A2 , 0
A4 , 0
etc.

이제 B=1인 A 열을 A열의 새 스프레드시트에 복사하여 붙여넣은 다음 B=0인 이전 스프레드시트의 A 열을 B열의 새 스프레드시트에 복사하여 붙여넣을 수 있습니다.

이렇게 하면 원하는 결과가 나올 것입니다(희망합니다).

관련 정보